本文整理了Java中leap.lang.json.JSON
类的一些代码示例,展示了JSON
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSON
类的具体详情如下:
包路径:leap.lang.json.JSON
类名称:JSON
暂无
代码示例来源:origin: org.leapframework/jmms-engine
private Object requireJsonModule() {
exports = JSON.decode(script);
return exports;
}
代码示例来源:origin: org.leapframework/jmms-engine
public Object parse(String s) {
return JSON.parse(s);
}
代码示例来源:origin: org.leapframework/leap-webunit
/**
* Parse the response content as json and decodes to map.
*/
default Map<String,Object> decodeJsonMap() {
return JSON.decodeMap(getContent());
}
代码示例来源:origin: org.leapframework/leap-webapi
@Override
public T getObject() {
if(t != null){
return t;
}else if (clzz != null){
if(m != null){
t = JSON.decode(JSON.encode(m),clzz);
}
return t;
}else {
return (T)m;
}
}
}
代码示例来源:origin: org.leapframework/leap-webapi
Type[] actualTypes = pType.getActualTypeArguments();
if (rawType.isAssignableFrom(List.class)) {
Object[] arr = JSON.decodeArray(jsonStr, (Class<?>) actualTypes[0]);
T val = (T) Arrays.stream(arr).collect(Collectors.toList());
return val;
} else if (rawType.isAssignableFrom(Map.class)) {
Map<String, Object> val = JSON.decodeMap(jsonStr, (Class<?>) actualTypes[0]);
return (T) val;
} else {
val = JSON.decode(jsonStr, (Class<T>) targetType);
代码示例来源:origin: org.leapframework/leap-lang
/**
* Creates a {@link JsonWriter} use {@link StringBuilder} as output.
*/
public static JsonWriter createWriter() {
return createWriter(new StringBuilder());
}
代码示例来源:origin: org.leapframework/leap-lang
@Override
public String toString() {
return JSON.stringify(map);
}
}
代码示例来源:origin: org.leapframework/leap-orm
@Override
public Object trySerialize(FieldMapping fm, Object plain) {
return JSON.encode(plain,settings);
}
代码示例来源:origin: org.leapframework/leap-lang
private List<KV> flat(){
List<KV> flat = new ArrayList<>();
list.forEach(kv -> {
String key = kv.key;
Object value = kv.value;
if(value == null || Beans.isSimpleProperty(value.getClass())){
flat.add(new KV(key,value));
}else {
JsonObject json = JsonObject.of(JSON.decodeMap(JSON.encode(value)));
addFlatList(key,json,flat);
}
});
return flat;
}
代码示例来源:origin: org.leapframework/jmms-engine
public MetaModel read(Resource file) {
String content = file.getContent().trim();
if (content.length() == 0) {
return null;
}
String name = Strings.upperFirst(Paths.getFileNameWithoutExtension(file.getFilename()));
JsonObject o = JSON.parse(file.getContent()).asJsonObject();
if(o.asMap().isEmpty()) {
return null;
}
MetaModel model = JSON.convert(o.asMap(), MetaModel.class);
if (!Strings.isEmpty(model.getClassName())) {
Class<?> c = Classes.tryForName(model.getClassName());
if (null == c) {
throw new IllegalStateException("Model class '" + model.getClassName() + "' not found!");
}
MType type = MTypes.getMType(c);
if (!type.isComplexType()) {
throw new IllegalStateException("The model class '" + model.getClassName() + "' must be complex type!");
}
MetaUtils.tryCopyModel(type.asComplexType(), model);
}
MApiModelBuilder am = nonValidateSwaggerReader.readModel(name, o.asMap(), new SwaggerTypeEx());
MetaUtils.tryCopyModel(am, model);
validator.validate("Model(" + model.getName() + ")", model);
return model;
}
代码示例来源:origin: org.leapframework/leap-lang
/**
* Creates a {@link JsonWriter} use {@link StringBuilder} as output.
*/
public static JsonWriter createWriter(JsonSettings settings) {
return writer().setSettings(settings).create();
}
代码示例来源:origin: org.leapframework/leap-lang
/**
* Parse the json string and converts the raw value to the target type
* @since 0.5.0b
*/
public static <T> List<T> decodeList(String json, Class<? extends T> valueType){
T[] obj = decodeArray(json,valueType);
return New.arrayList(obj);
}
代码示例来源:origin: org.leapframework/leap-lang
/**
* Encodes the value to json string.
*/
public static String encode(Object value){
return createWriter().value(value).toString();
}
代码示例来源:origin: org.leapframework/jmms-engine
public String json(Object o) {
return JSON.stringify(o);
}
代码示例来源:origin: org.leapframework/jmms-modules-redis
public String encode(Object value) {
return null == value ? Strings.EMPTY : JSON.encode(value);
}
代码示例来源:origin: org.leapframework/leap-lang
/**
* Creates a {@link JsonWriter} use the given {@link Appendable} as output.
*/
public static JsonWriter createWriter(Appendable out, JsonSettings settings) {
return writer(out).setSettings(settings).create();
}
代码示例来源:origin: org.leapframework/leap-webunit
/**
* Parse the response content as json and decodes to array.
*/
default <T> T[] decodeJsonArray(Class<T> componentType) {
return JSON.decodeArray(getContent(), componentType);
}
代码示例来源:origin: org.leapframework/jmms-engine
public Object decode(String s) {
return JSON.decode(s);
}
}
代码示例来源:origin: org.leapframework/leap-webunit
/**
* Returns the content of response body as {@link JsonValue}.
*/
default JsonValue getJson() {
return JSON.parse(getContent());
}
代码示例来源:origin: org.leapframework/leap-lang
/**
* Parse the json string and converts the raw value to the target type
* @since 0.5.0b
*/
public static <T> Map<String, T> decodeMap(String json, Class<? extends T> valueType){
Map<String, Object> map = decodeMap(json);
for(Map.Entry<String, Object> entry : map.entrySet()){
entry.setValue(Converts.convert(entry.getValue(),valueType, null, convertContext));
}
return (Map<String, T>) map;
}
内容来源于网络,如有侵权,请联系作者删除!