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); }
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); }
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}; }
/** 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)} * @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); }
/** * @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 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); }
/** * @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); }