MCPcopy Create free account
hub / github.com/Var3D/var3dframe / getIt

Method getIt

core/src/core/java/var3d/net/center/json/VJSON.java:80–97  ·  view source on GitHub ↗

获取json路径下的某个元素(如果路径不存在返回null值,并自动创建路径) @param jsonPath 例如"rpg/man/hp",rpg和man为jsonObject @return

(String jsonPath)

Source from the content-addressed store, hash-verified

78 * @return
79 */
80 public Object getIt(String jsonPath) {
81 jsonPath = jsonPath.replaceAll("\\.", "/");
82 String[] paths = jsonPath.split("/");
83 Object o = null;
84 JSONObject object = jsonObj;
85 try {
86 for (String name : paths) {
87 if (object.isNull(name))
88 object.put(name, new JSONObject());
89 o = object.get(name);
90 if (o instanceof JSONObject)
91 object = (JSONObject) o;
92 }
93 } catch (JSONException e) {
94 e.printStackTrace();
95 }
96 return o;
97 }
98
99 /**
100 * 新增,修改,删除(修改所在路径的值,如果不存在则自动创建路径。如果值为null则为删除)

Callers 2

putMethod · 0.95
editMethod · 0.95

Calls 3

isNullMethod · 0.95
putMethod · 0.95
getMethod · 0.95

Tested by

no test coverage detected