TreeObject implements Serializable, Cloneable { public TreeObject() { } TreeObject();  TreeObject(boolean bool);  TreeObject(Boolean bool);  TreeObject(byte b);  TreeObject(Byte b);  TreeObject(byte[] bytes);  TreeObject(Byte[] bytes);  TreeObject(char c);  TreeObject(Character c);  TreeObject(Collection<?> c);  TreeObject(double d);  TreeObject(Double d);  TreeObject(float f);  TreeObject(Float f);  TreeObject(int i);  TreeObject(Integer i);  TreeObject(long l);  TreeObject(long t, boolean isTime);  TreeObject(Long l);  TreeObject(Long t, boolean isTime);  TreeObject(Map<?, ?> m);  TreeObject(short s);  TreeObject(Short s);  TreeObject(String s);  TreeObject(String s, boolean isMix);  TreeObject(TreeObject tObject);  TreeObject(Object o);  TreeObject(Object o, int type); static TreeObject fromJson(String jsonStr); static TreeObject fromJson(JSONObject json); JSONObject toJson(); static JSONObject toJson(TreeObject tObject); static TreeObject fromXml(String xml); String toXml(); static String toXml(TreeObject tObject); TreeObject add(boolean b); TreeObject add(Boolean b); TreeObject add(byte b); TreeObject add(Byte b); TreeObject add(byte[] bytes); TreeObject add(Byte[] bytes); TreeObject add(char c); TreeObject add(Character c); TreeObject add(double d); TreeObject add(Double d); TreeObject add(float f); TreeObject add(Float f); TreeObject add(int i); TreeObject add(Integer i); TreeObject add(long l); TreeObject add(long t, boolean isTime); TreeObject add(Long l); TreeObject add(Long t, boolean isTime); TreeObject add(Object o); TreeObject add(Object o, int type); TreeObject add(short s); TreeObject add(Short s); TreeObject add(String s); TreeObject add(String s, boolean isMix); TreeObject add(TreeObject tObject); TreeObject put(String k, boolean b); TreeObject put(String k, Boolean b); TreeObject put(String k, byte b); TreeObject put(String k, Byte b); TreeObject put(String k, byte[] bytes); TreeObject put(String k, Byte[] bytes); TreeObject put(String k, char c); TreeObject put(String k, Character c); TreeObject put(String k, double d); TreeObject put(String k, Double d); TreeObject put(String k, float f); TreeObject put(String k, Float f); TreeObject put(String k, int i); TreeObject put(String k, Integer i); TreeObject put(String k, long l); TreeObject put(String k, long t, boolean isTime); TreeObject put(String k, Long l); TreeObject put(String k, Long t, boolean isTime); TreeObject put(String k, Object o); TreeObject put(String k, Object o, int type); TreeObject put(String k, short s); TreeObject put(String k, Short s); TreeObject put(String k, String s); TreeObject put(String k, String s, boolean isMix); TreeObject put(String k, TreeObject tObject); boolean has(int index); boolean has(String key); boolean isList(); boolean isMap(); boolean isValue(); int getType(); List<TreeObject> getList(); Map<String, TreeObject> getMap(); Object getObject(); boolean toBooleanValue(); byte toByteValue(); byte[] toBytesValue(); char toCharValue(); double toDoubleValue(); float toFloatValue(); int toIntValue(); long toLongValue(); String toMixStringValue(); short toShortValue(); String toStringValue(); long toTimeValue(); TreeObject get(int index); TreeObject get(int index, TreeObject defaultValue); TreeObject get(String key); TreeObject get(String key, TreeObject defaultValue); boolean getBoolean(int index); boolean getBoolean(int index, boolean defaultValue); boolean getBoolean(String key); boolean getBoolean(String key, boolean defaultValue); byte getByte(int index); byte getByte(int index, byte defaultValue); byte getByte(String key); byte getByte(String key, byte defaultValue); byte[] getBytes(int index); byte[] getBytes(int index, byte[] defaultValue); byte[] getBytes(String key); byte[] getBytes(String key, byte[] defaultValue); char getChar(int index); char getChar(int index, char defaultValue); char getChar(String key); char getChar(String key, char defaultValue); double getDouble(int index); double getDouble(int index, double defaultValue); double getDouble(String key); double getDouble(String key, double defaultValue); float getFloat(int index); float getFloat(int index, float defaultValue); float getFloat(String key); float getFloat(String key, float defaultValue); int getInt(int index); int getInt(int index, int defaultValue); int getInt(String key); int getInt(String key, int defaultValue); long getLong(int index); long getLong(int index, long defaultValue); long getLong(String key); long getLong(String key, long defaultValue); String getMixString(int index); String getMixString(int index, String defaultValue); String getMixString(String key); String getMixString(String key, String defaultValue); short getShort(int index); short getShort(int index, short defaultValue); short getShort(String key); short getShort(String key, short defaultValue); String getString(int index); String getString(int index, String defaultValue); String getString(String key); String getString(String key, String defaultValue); long getTime(int index); long getTime(int index, long defaultValue); long getTime(String key); long getTime(String key, long defaultValue); static final int MODE_VALUE; static final int MODE_ARRAY; static final int MODE_MAP; static final int TYPE_NULL; static final int TYPE_INTEGER; static final int TYPE_MIX_STRING; static final int TYPE_STRING; static final int TYPE_LONG; static final int TYPE_TIME; static final int TYPE_BOOLEAN; static final int TYPE_FLOAT; static final int TYPE_DOUBLE; static final int TYPE_MAP; static final int TYPE_COLLECTION; static final int TYPE_BYTE; static final int TYPE_CHAR; static final int TYPE_SHORT; static final int TYPE_BYTES; static final int TYPE_OBJECT; static final int TYPE_UNKNOWN; static final int TYPE_TREE_OBJECT; }
@Test public void treeObject() { Object _id = UUIDUtils.UUID(); TreeObject _target = new TreeObject() .put("id", _id) .put("category", new Byte[]{1, 2, 3, 4}) .put("create_time", new Date().getTime(), true) .put("is_locked", true) .put("detail", new TreeObject() .put("real_name", "汉字将被混淆", true) .put("age", 32)); TreeObject _list = new TreeObject(); _list.add("list item 1"); _list.add("list item 2"); TreeObject _map = new TreeObject(); _map.put("key1", "keyvalue1"); _map.put("key2", "keyvalue2"); TreeObject idsT = new TreeObject(); idsT.put("ids", _list); idsT.put("maps", _map); System.out.println(idsT.get("ids").isList()); System.out.println(idsT.get("ids").getList()); System.out.println(idsT.get("maps").isMap()); System.out.println(idsT.get("maps").getMap()); _target.put("map", _map); _target.put("list", _list); System.out.println(_target.get("detail").getMixString("real_name")); String _jsonStr = _target.toJson().toJSONString(); System.out.println(_jsonStr); String _jsonStrTmp = (TreeObject.fromJson(_target.toJson())).toJson().toJSONString(); System.out.println(_jsonStrTmp); System.out.println(_jsonStr.equals(_jsonStrTmp)); }