org.nutz.json.Json.fromJson()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中org.nutz.json.Json.fromJson()方法的一些代码示例,展示了Json.fromJson()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.fromJson()方法的具体详情如下:
包路径:org.nutz.json.Json
类名称:Json
方法名:fromJson

Json.fromJson介绍

[英]从文本输入流中生成 JAVA 对象。
[中]从文本输入流中生成 JAVA对象。

代码示例

代码示例来源:origin: nutzam/nutz

@SuppressWarnings("unchecked")
public static <T> T fromJson(PType<T> type, Reader reader)
    throws JsonException {
  return (T) fromJson((Type)type, reader);
}

代码示例来源:origin: nutzam/nutz

@SuppressWarnings("unchecked")
public static <T> T fromJson(PType<T> type, CharSequence cs)
    throws JsonException {
  return (T)fromJson((Type)type, cs);
}

代码示例来源:origin: nutzam/nutz

@SuppressWarnings("unchecked")
public MapLoader(String json) {
  this((Map<String, Map<String, Object>>) Json.fromJson(json));
}

代码示例来源:origin: nutzam/nutz

@Override
public Map cast(String src, Class<?> toType, String... args) throws FailToCastObjectException {
  return (Map) Json.fromJson(toType, src);
}

代码示例来源:origin: nutzam/nutz

@Override
public Set cast(String src, Class<?> toType, String... args) throws FailToCastObjectException {
  return Json.fromJson(Set.class, src);
}

代码示例来源:origin: nutzam/nutz

public NumberNode(String num) {
  v = Json.fromJson(num);
}

代码示例来源:origin: nutzam/nutz

/**
 * 
 * @param reader 模板流
 */
public StructureConvert(Reader reader){
  Object obj = Json.fromJson(reader);
  loadRelation(obj, "");
}
/**

代码示例来源:origin: nutzam/nutz

private static Object parse(Type type, Reader reader) {
  Object obj = fromJson(reader);
  if (type != null)
    return Mapl.maplistToObj(obj, type);
  return obj;
}

代码示例来源:origin: nutzam/nutz

@Override
public Collection cast(String src, Class<?> toType, String... args)
    throws FailToCastObjectException {
  return (Collection) Json.fromJson(toType, Lang.inr(src));
}

代码示例来源:origin: nutzam/nutz

@SuppressWarnings("unchecked")
public FilterConvertImpl(String path) {
  items = (List<String>) Json.fromJson(Streams.fileInr(path));
}

代码示例来源:origin: nutzam/nutz

@SuppressWarnings("unchecked")
public static Request create(String url, METHOD method, String paramsAsJson, Header header) {
  return create(url, method, (Map<String, Object>) Json.fromJson(paramsAsJson), header);
}

代码示例来源:origin: nutzam/nutz

@SuppressWarnings("unchecked")
public static Request create(String url, METHOD method, String paramsAsJson) {
  return create(url, method, (Map<String, Object>) Json.fromJson(paramsAsJson));
}

代码示例来源:origin: nutzam/nutz

/**
 * 从 JSON 字符串中,获取 JAVA 对象。 实际上,它就是用一个 Read 包裹了的字符串。
 * <p>
 * 请参看函数 ‘Object fromJson(Reader reader)’ 的描述
 * 
 * @param cs
 *            JSON 字符串
 * @return JAVA 对象
 * @throws JsonException
 * 
 * @see #fromJson(Reader reader)
 */
public static Object fromJson(CharSequence cs) throws JsonException {
  return fromJson(Lang.inr(cs));
}

代码示例来源:origin: nutzam/nutz

public static Header create(String properties) {
  return create((Map<String, String>) Json.fromJson(properties));
}

代码示例来源:origin: nutzam/nutz

protected void loadFromReader(Reader reader) {
  String s = Lang.readAll(reader);
  Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>) Json.fromJson(s);
  if (null != map && map.size() > 0)
    getMap().putAll(map);
}

代码示例来源:origin: nutzam/nutz

public Object getReferObject(    ServletContext sc,
              HttpServletRequest req,
              HttpServletResponse resp, String[] pathArgs) {
    // Read all as String
    try {
      //TODO URL传来的参数会丢失
      return Json.fromJson(Streams.utf8r(req.getInputStream()));
    }
    catch (Exception e) {
      throw Lang.wrapThrow(e);
    }
  }
}

代码示例来源:origin: nutzam/nutz

/**
 * 
 * @param path 模板文件路径
 */
public StructureConvert(String path){
  Object obj = Json.fromJson(Streams.fileInr(path));
  loadRelation(obj, "");
}
/**

代码示例来源:origin: nutzam/nutz

@SuppressWarnings("unchecked")
private static void evalPathMap(ActionInfo ai, PathMap pathMap) {
  if (pathMap != null) {
    ai.setPathMap(Json.fromJson(Map.class, pathMap.value()));
  }
}

代码示例来源:origin: nutzam/nutz

@Override
public Object cast(String src, Class<?> toType, String... args)
    throws FailToCastObjectException {
  if (Strings.isQuoteByIgnoreBlank(src, '[', ']')) {
    return Json.fromJson(toType, src);
  }
  String[] ss = Strings.splitIgnoreBlank(src);
  return Lang.array2array(ss, toType.getComponentType());
}

代码示例来源:origin: nutzam/nutz

@Override
public Object cast(String src, Class<?> toType, String... args)
    throws FailToCastObjectException {
  if (Strings.isQuoteByIgnoreBlank(src, '{', '}'))
    return Json.fromJson(toType, src);
  return Mirror.me(toType).born(src);
}

相关文章