Skip to content

Instantly share code, notes, and snippets.

@wertgit
Last active March 22, 2016 11:07
Show Gist options
  • Save wertgit/20bcb00c2d1aa6742bba to your computer and use it in GitHub Desktop.
Save wertgit/20bcb00c2d1aa6742bba to your computer and use it in GitHub Desktop.
JsonConversionUtil
if (matcher.matches()) {
// Handle as array
String fieldName = matcher.group(1);
int index = Integer.parseInt(matcher.group(2));
JSONArray newArrayStep;
if (root.has(fieldName)) {
newArrayStep = root.getJSONArray(fieldName);
} else {
newArrayStep = new JSONArray();
root.put(fieldName, newArrayStep);
}
JSONObject newStep = new JSONObject();
newArrayStep.put(index, newStep);
return buildHolder(newStep, steps, ++currentStep);
} else {
JSONObject newStep;
if (root.has(steps[currentStep])) {
newStep = root.getJSONObject(steps[currentStep]);
} else {
newStep = new JSONObject();
root.put(steps[currentStep], newStep);
}
return buildHolder(newStep, steps, ++currentStep);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment