本文整理汇总了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();
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例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));
}
示例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));
}
示例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));
}
示例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();
}
示例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();
}