当前位置: 首页>>代码示例>>Java>>正文


Java JSONUtil类代码示例

本文整理汇总了Java中net.minidev.json.JSONUtil的典型用法代码示例。如果您正苦于以下问题:Java JSONUtil类的具体用法?Java JSONUtil怎么用?Java JSONUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JSONUtil类属于net.minidev.json包,在下文中一共展示了JSONUtil类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MapType

import net.minidev.json.JSONUtil; //导入依赖的package包/类
public MapType(JsonReader base, ParameterizedType type) {
	super(base);
	this.type = type;
	this.rawClass = (Class<?>) type.getRawType();
	if (rawClass.isInterface())
		instance = JSONObject.class;
	else
		instance = rawClass;
	ba = BeansAccess.get(instance, JSONUtil.JSON_SMART_FIELD_FILTER);

	keyType = type.getActualTypeArguments()[0];
	valueType = type.getActualTypeArguments()[1];
	if (keyType instanceof Class)
		keyClass = (Class<?>) keyType;
	else
		keyClass = (Class<?>) ((ParameterizedType) keyType).getRawType();
	if (valueType instanceof Class)
		valueClass = (Class<?>) valueType;
	else
		valueClass = (Class<?>) ((ParameterizedType) valueType).getRawType();
}
 
开发者ID:netplex,项目名称:json-smart-v2,代码行数:22,代码来源:CollectionMapper.java

示例2: MapClass

import net.minidev.json.JSONUtil; //导入依赖的package包/类
public MapClass(JsonReader base, Class<?> type) {
	super(base);
	this.type = type;
	if (type.isInterface())
		this.instance = JSONObject.class;
	else
		this.instance = type;
	this.ba = BeansAccess.get(instance, JSONUtil.JSON_SMART_FIELD_FILTER);
}
 
开发者ID:netplex,项目名称:json-smart-v2,代码行数:10,代码来源:CollectionMapper.java

示例3: ListType

import net.minidev.json.JSONUtil; //导入依赖的package包/类
public ListType(JsonReader base, ParameterizedType type) {
	super(base);
	this.type = type;
	this.rawClass = (Class<?>) type.getRawType();
	if (rawClass.isInterface())
		instance = JSONArray.class;
	else
		instance = rawClass;
	ba = BeansAccess.get(instance, JSONUtil.JSON_SMART_FIELD_FILTER); // NEW
	valueType = type.getActualTypeArguments()[0];
	if (valueType instanceof Class)
		valueClass = (Class<?>) valueType;
	else
		valueClass = (Class<?>) ((ParameterizedType) valueType).getRawType();
}
 
开发者ID:netplex,项目名称:json-smart-v2,代码行数:16,代码来源:CollectionMapper.java

示例4: ListClass

import net.minidev.json.JSONUtil; //导入依赖的package包/类
public ListClass(JsonReader base, Class<?> clazz) {
	super(base);
	this.type = clazz;
	if (clazz.isInterface())
		instance = JSONArray.class;
	else
		instance = clazz;
	ba = BeansAccess.get(instance, JSONUtil.JSON_SMART_FIELD_FILTER);
}
 
开发者ID:netplex,项目名称:json-smart-v2,代码行数:10,代码来源:CollectionMapper.java

示例5: writeJSONString

import net.minidev.json.JSONUtil; //导入依赖的package包/类
public <E> void writeJSONString(E value, Appendable out, JSONStyle compression) throws IOException {
	try {
		Class<?> cls = value.getClass();
		boolean needSep = false;
		@SuppressWarnings("rawtypes")
		BeansAccess fields = BeansAccess.get(cls, JSONUtil.JSON_SMART_FIELD_FILTER);
		out.append('{');
		for (Accessor field : fields.getAccessors()) {
			@SuppressWarnings("unchecked")
			Object v = fields.get(value, field.getIndex());
			if (v == null && compression.ignoreNull())
				continue;
			if (needSep)
				out.append(',');
			else
				needSep = true;
			String key = field.getName();
			JSONObject.writeJSONKV(key, v, out, compression);
		}
		out.append('}');
	} catch (IOException e) {
		throw e;
	}
}
 
开发者ID:netplex,项目名称:json-smart-v2,代码行数:25,代码来源:BeansWriterASM.java

示例6: writeJSONString

import net.minidev.json.JSONUtil; //导入依赖的package包/类
public <E> void writeJSONString(E value, Appendable out, JSONStyle compression) throws IOException {
	try {
		Class<?> cls = value.getClass();
		boolean needSep = false;
		@SuppressWarnings("rawtypes")
		BeansAccess fields = BeansAccess.get(cls, JSONUtil.JSON_SMART_FIELD_FILTER);
		out.append('{');
		for (Accessor field : fields.getAccessors()) {
			@SuppressWarnings("unchecked")
			Object v = fields.get(value, field.getIndex());
			if (v == null && compression.ignoreNull())
				continue;
			if (needSep)
				out.append(',');
			else
				needSep = true;
			String key = field.getName();
			key = rename(key);
			JSONObject.writeJSONKV(key, v, out, compression);
		}
		out.append('}');
	} catch (IOException e) {
		throw e;
	}
}
 
开发者ID:netplex,项目名称:json-smart-v2,代码行数:26,代码来源:BeansWriterASMRemap.java

示例7: setValue

import net.minidev.json.JSONUtil; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void setValue(Object current, String key, Object value) {
	((Map<Object, Object>) current).put(JSONUtil.convertToX(key, keyClass),
			JSONUtil.convertToX(value, valueClass));
}
 
开发者ID:netplex,项目名称:json-smart-v2,代码行数:7,代码来源:CollectionMapper.java

示例8: getValue

import net.minidev.json.JSONUtil; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object getValue(Object current, String key) {
	return ((Map<String, Object>) current).get(JSONUtil.convertToX(key, keyClass));
}
 
开发者ID:netplex,项目名称:json-smart-v2,代码行数:6,代码来源:CollectionMapper.java

示例9: addValue

import net.minidev.json.JSONUtil; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void addValue(Object current, Object value) {
	((List<Object>) current).add(JSONUtil.convertToX(value, valueClass));
}
 
开发者ID:netplex,项目名称:json-smart-v2,代码行数:6,代码来源:CollectionMapper.java

示例10: Bean

import net.minidev.json.JSONUtil; //导入依赖的package包/类
public Bean(JsonReader base, Class<T> clz) {
	super(base);
	this.clz = clz;
	this.ba = BeansAccess.get(clz, JSONUtil.JSON_SMART_FIELD_FILTER);
	this.index = ba.getMap();
}
 
开发者ID:netplex,项目名称:json-smart-v2,代码行数:7,代码来源:BeansMapper.java

示例11: BeanNoConv

import net.minidev.json.JSONUtil; //导入依赖的package包/类
public BeanNoConv(JsonReader base, Class<T> clz) {
	super(base);
	this.clz = clz;
	this.ba = BeansAccess.get(clz, JSONUtil.JSON_SMART_FIELD_FILTER);
	this.index = ba.getMap();
}
 
开发者ID:netplex,项目名称:json-smart-v2,代码行数:7,代码来源:BeansMapper.java


注:本文中的net.minidev.json.JSONUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。