/** * @param s String containing JSON object or array. * @return A Map, Object array or primitive array parsed from the JSON. */ public static Object parse(String s) { return __default.parse(new StringSource(s),false); }
source.next(); Object value=contextFor(name).parse(source); map.put(name,value);
/** Construct a literal JSON instance for use by {@link JSON#toString(Object)}. * If {@link Log#isDebugEnabled()} is true, the JSON will be parsed to check validity * @param json A literal JSON string. */ public Literal(String json) { if (Log.isDebugEnabled()) parse(json); _json=json; }
/** * @param s Stream containing JSON object or array. * @param stripOuterComment If true, an outer comment around the JSON is ignored. * @return A Map, Object array or primitive array parsed from the JSON. */ public static Object parse(Reader in, boolean stripOuterComment) throws IOException { return __default.parse(new ReaderSource(in),stripOuterComment); }
/** * @param s String containing JSON object or array. * @param stripOuterComment If true, an outer comment around the JSON is ignored. * @return A Map, Object array or primitive array parsed from the JSON. */ public static Object parse(String s, boolean stripOuterComment) { return __default.parse(new StringSource(s),stripOuterComment); }
/** * @param in Reader containing JSON object or array. * @return A Map, Object array or primitive array parsed from the JSON. */ public static Object parse(Reader in) throws IOException { return __default.parse(new ReaderSource(in),false); }
/** Convert JSON to Object * @param json The json to convert * @return The object */ public Object fromJSON(String json) { Source source = new StringSource(json); return parse(source); }
/** * @deprecated use {@link #parse(Reader, boolean)} * @param s Stream containing JSON object or array. * @param stripOuterComment If true, an outer comment around the JSON is ignored. * @return A Map, Object array or primitive array parsed from the JSON. */ public static Object parse(InputStream in, boolean stripOuterComment) throws IOException { return __default.parse(new StringSource(IO.toString(in)),stripOuterComment); }
/** * @deprecated use {@link #parse(Reader)} * @param in Reader containing JSON object or array. * @return A Map, Object array or primitive array parsed from the JSON. */ public static Object parse(InputStream in) throws IOException { return __default.parse(new StringSource(IO.toString(in)),false); }
@Override public List<Variant> read() { String line = null; try { line = reader.readLine(); } catch (IOException e) { e.printStackTrace(); } return line != null ? Collections.singletonList(new Variant(jsonObjectMapper.convertValue(JSON.parse(line), VariantAvro.class))) : null; }
public Message[] parse(String s) throws IOException { Object batch=_batchJSON.parse(new JSON.StringSource(s)); if (batch==null) return new Message[0]; if (batch.getClass().isArray()) return (Message[])batch; return new Message[]{(Message)batch}; }
public Message[] parse(String s) throws IOException { Object batch=_batchJSON.parse(new JSON.StringSource(s)); if (batch == null) return new Message[0]; if (batch.getClass().isArray()) return (Message[])batch; return new Message[] {(Message)batch}; }
@SuppressWarnings("unchecked") private static Map<String, Object> parse(String jsonString) { return (Map<String, Object>)JSON.parse(jsonString); }
public void parseTo(String fodder, List<Message> messages) { Object batch=_batchJSON.parse(new JSON.StringSource(fodder)); if (batch == null) return; if (batch.getClass().isArray()) { Message[] msgs=(Message[])batch; for (int m=0; m < msgs.length; m++) messages.add(msgs[m]); } else messages.add((Message)batch); }
protected Object filterJSON(Client from, Channel to, JSON.Generator generator) { String json=JSON.toString(generator); Object data=JSON.parse(json); return filter(from,to,data); }
protected Object filterJSON(Client from, Channel to, JSON.Literal json) { Object data=JSON.parse(json.toString()); return filter(from,to,data); }
protected Object filterJSON(Client from, Channel to, JSON.Literal json) { Object data = JSON.parse(json.toString()); return filter(from,to,data); }
protected Object filterJSON(Client from, Channel to, JSON.Generator generator) { String json = JSON.toString(generator); Object data = JSON.parse (json); return filter(from,to,data); }