/** * @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); }
/** * @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); }
public void toJSON(Output out) { convertor.toJSON(object,out); } });
/** 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; }
public static String toString(Map object) { StringBuffer buffer=new StringBuffer(__default.getStringBufferSize()); synchronized (buffer) { __default.appendMap(buffer,object); return buffer.toString(); } }
public static String toString(Object object) { StringBuffer buffer=new StringBuffer(__default.getStringBufferSize()); synchronized (buffer) { __default.append(buffer,object); return buffer.toString(); } }
public static Continuation getContinuation(HttpServletRequest request, Object mutex) { Continuation continuation = (Continuation) request.getAttribute("org.mortbay.jetty.ajax.Continuation"); if (continuation==null) continuation=new WaitingContinuation(mutex); else if (mutex!=null) continuation.setMutex(mutex); return continuation; } }
public boolean hasNext() { getNext(); if (_next<0) { scratch=null; return false; } return true; }
/** * Register a {@link Convertor} for a class or interface. * @param forClass The class or interface that the convertor applies to * @param convertor the convertor */ public static void registerConvertor(Class forClass, Convertor convertor) { __default.addConvertor(forClass,convertor); }
public void appendJSON(final StringBuffer buffer, final Convertor convertor, final Object object) { appendJSON(buffer,new Convertible() { public void fromJSON(Map object) { } public void toJSON(Output out) { convertor.toJSON(object,out); } }); }
public void appendJSON(StringBuffer buffer, Generator generator) { generator.addJSON(buffer); }
public void appendString(StringBuffer buffer, String string) { if (string==null) { appendNull(buffer); return; } QuotedStringTokenizer.quote(buffer,string); }
/** * @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 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); }
public char next() { getNext(); char c=(char)_next; _next=-1; return c; }
/** 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); }
public char peek() { getNext(); return (char)_next; }
/** * @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); }