01: /*
02: * $Id: JSONValue.java,v 1.1 2006/04/15 14:37:04 platform Exp $
03: * Created on 2006-4-15
04: */
05: package org.zkforge.json.simple;
06:
07: import java.io.Reader;
08: import java.io.StringReader;
09:
10: import org.zkforge.json.simple.parser.JSONParser;
11:
12: /**
13: * @author FangYidong<fangyidong@yahoo.com.cn>
14: */
15: public class JSONValue {
16: /**
17: * parse into java object from input source.
18: * @param in
19: * @return instance of : JSONObject,JSONArray,String,Boolean,Long,Double or null
20: */
21: public static Object parse(Reader in) {
22: try {
23: JSONParser parser = new JSONParser();
24: return parser.parse(in);
25: } catch (Exception e) {
26: return null;
27: }
28: }
29:
30: public static Object parse(String s) {
31: StringReader in = new StringReader(s);
32: return parse(in);
33: }
34: }
|