本文整理了Java中leap.lang.json.JSON.decode()
方法的一些代码示例,展示了JSON.decode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSON.decode()
方法的具体详情如下:
包路径:leap.lang.json.JSON
类名称:JSON
方法名:decode
[英]Parse the json string and returns the raw value.
The raw value may be : map, list, null or simple value.
[中]解析json字符串并返回原始值。
原始值可以是:map、list、null或简单值。
代码示例来源:origin: org.leapframework/jmms-engine
private Object requireJsonModule() {
exports = JSON.decode(script);
return exports;
}
代码示例来源:origin: org.leapframework/leap-lang
public Object deserialize(String string) {
return JSON.decode(string);
}
代码示例来源:origin: org.leapframework/jmms-engine
public Object decode(String s) {
return JSON.decode(s);
}
}
代码示例来源:origin: org.leapframework/jmms-engine
protected Input parse(String line) {
return JSON.decode(line, Input.class);
}
代码示例来源:origin: org.leapframework/leap-lang
/**
* Parse the json string and returns the result as {@link JsonValue}.
*/
public static JsonValue parse(String json) {
return JsonValue.of(decode(json));
}
代码示例来源:origin: org.leapframework/leap-webunit
/**
* Parse the response content as json and decodes to the given type.
*/
default <T> T decodeJson(Class<T> type) {
return JSON.decode(getContent(), type);
}
代码示例来源:origin: org.leapframework/leap-core
protected T doConvert(String s) {
if(null == s || s.length() == 0) {
return null;
}else{
if(complex) {
return JSON.decode(s, type);
}else{
return Converts.convert(s, type);
}
}
}
}
代码示例来源:origin: org.leapframework/leap-lang
/**
* Returns the response body as decoded json value.
*/
default Object json() throws HttpIOException {
return JSON.decode(getString());
}
代码示例来源:origin: org.leapframework/leap-lang
/**
* Parse the json string and returns the result as {@link JsonValue}.
*/
public static JsonValue parse(Reader json) {
return JsonValue.of(decode(json));
}
代码示例来源:origin: org.leapframework/leap-orm
@Override
public Object deserialize(FieldMapping fm, Object encoded) {
return JSON.decode(toString(encoded));
}
代码示例来源: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-orm
@Override
public Object deserialize(FieldMapping fm, Object encoded, Class<?> type, Type genericType) {
return JSON.decode(toString(encoded), type, genericType);
}
代码示例来源:origin: org.leapframework/jmms-modules-redis
public Object decode(String encoded) {
return Strings.isEmpty(encoded) ? null : JSON.decode(encoded);
}
代码示例来源:origin: org.leapframework/leap-lang
public Object tryDeserialize(String string) {
if(Strings.isEmpty(string)){
return null;
}
string = string.trim();
if("null".equals(string)){
return null;
}
if((string.startsWith("[") && string.endsWith("]")) || (string.startsWith("{") && string.endsWith("}"))){
return JSON.decode(string);
}
return string;
}
}
代码示例来源:origin: org.leapframework/jmms-engine
public void read(MetaApi api, Resource resource) {
Map<String, MetaField> map =
(Map<String,MetaField>)JSON.decode(resource.getContent(), field.getType(), field.getGenericType());
api.getDomains().putAll(map);
}
代码示例来源:origin: org.leapframework/leap-webapi
@Override
public ApiMetadataBuilder read(Reader reader) throws IOException {
String content = IO.readString(reader).trim();
Map<String,Object> swagger;
if(content.startsWith("{")) {
swagger = JSON.decode(content);
}else{
swagger = YAML.decode(content);
}
ApiMetadataBuilder m = new ApiMetadataBuilder();
readSwagger(swagger, m);
return m;
}
代码示例来源:origin: org.leapframework/jmms-engine
private void loadResource(Resource resource) {
Dbms mdb = JSON.decode(resource.getContent(), Dbms.class);
beanValidator.validate(mdb);
log.debug("Load database '{}', drive class name : {}", mdb.getName(), mdb.getDriverClassName());
map.put(mdb.getName().toLowerCase(), mdb);
}
}
代码示例来源:origin: org.leapframework/leap-core
@Override
public <T> Property<T> getDynaProperty(String name, Class<T> type) {
if(null != propertyProvider) {
try {
Property<T> p = propertyProvider.getDynaProperty(name, type);
return p;
} catch (UnsupportedDynaPropertyException e) {
log.info("property {0} unsupported by {1}, use local config",name,propertyProvider.getClass());
}
}
String v = properties.get(name);
if(null == v || v.isEmpty()) {
return new NullProperty<>();
}
TypeInfo ti = Types.getTypeInfo(type,null);
if(ti.isComplexType()) {
return new SimpleProperty<>(type, JSON.decode(v, type));
}else{
return new SimpleProperty<>(type, Converts.convert(v, type));
}
}
代码示例来源:origin: org.leapframework/jmms-engine
public Expression convertToExpr(String value) {
if(EL.hasPrefixAndSuffix(value)) {
return el.createExpression(EL.removePrefixAndSuffix(value));
}
if(vars.checkVariableExists(value)) {
return new VariableExpression(vars, value);
}
int dotIndex = value.indexOf('.');
if(dotIndex > 0) {
String name = value.substring(0, dotIndex);
if(vars.checkVariableExists(name)) {
return el.createExpression(VariableExpression.ENV_PREFIX + value);
}
}
try {
return new ValuedExpression(JSON.decode(value));
}catch (Exception e) {
return new ValuedExpression(value);
}
}
代码示例来源:origin: org.leapframework/jmms-engine
public void read(MetaApi api, Resource resource, boolean global) {
JsonValue v = JsonValue.of(JSON.decode(resource.getContent()));
String path = !global ? PathDefParser.path("/app/operations/", resource) : null;
if(v.isObject()) {
read(api, global, path,(Map)v.raw());
}else if(v.isArray()) {
for(Object map : v.asArray()) {
read(api, global, path,(Map)map);
}
}else {
throw new IllegalStateException("Invalid json format of tags, must be an array or an object");
}
}
内容来源于网络,如有侵权,请联系作者删除!