Last active
March 22, 2016 11:07
-
-
Save wertgit/20bcb00c2d1aa6742bba to your computer and use it in GitHub Desktop.
JsonConversionUtil
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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