* TreeItem.
*/
private void addChildren(TreeItem treeItem, JSONValue jsonValue) {
JSONArray jsonArray;
JSONObject jsonObject;
JSONString jsonString;
if ((jsonArray = jsonValue.isArray()) != null) {
for (int i = 0; i < jsonArray.size(); ++i) {
TreeItem child = treeItem.addItem(getChildText("["
+ Integer.toString(i) + "]"));
addChildren(child, jsonArray.get(i));
}
} else if ((jsonObject = jsonValue.isObject()) != null) {
Set<String> keys = jsonObject.keySet();
for (String key : keys) {
TreeItem child = treeItem.addItem(getChildText(key));
addChildren(child, jsonObject.get(key));
}
} else if ((jsonString = jsonValue.isString()) != null) {
// Use stringValue instead of toString() because we don't want escaping
treeItem.addItem(SafeHtmlUtils.fromString(jsonString.stringValue()));
} else {
// JSONBoolean, JSONNumber, and JSONNull work well with toString().
treeItem.addItem(getChildText(jsonValue.toString()));
}
}