Created
September 24, 2018 22:02
-
-
Save codeamt/384d8b6b4ae1a5bde953c20634c7bf9a to your computer and use it in GitHub Desktop.
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
public class JsonUtils { | |
public static Sandwich parseSandwichJson(String json) { | |
try { | |
/* Step One: Convert json string to JSON object */ | |
JSONObject base = new JSONObject(json); | |
/* Step Two: Parse the Base Object's Keys Into Autonomous Objects/Strings for Serializing */ | |
// Handle anomolies first | |
// Parsing the name key | |
// Coerce name key to JSON object called "name" | |
// Access the mainName key of the name object store it's value as String | |
// Coerce the alsoKnownAs key to a JSON array called "altNames" | |
// Instantiate Array Literal for Alt Names called "altNamesList" | |
// Loop through altNames JSON array | |
// Add each item in altNames to altNamesList | |
// Parsing the ingredients key | |
// Coerce ingredients key to a JSON array called "ingredients" | |
// Instantiate Array Literal for Ingredients called "ingredientsList" | |
// Loop through ingredients JSON array | |
// Add each item in ingredients to the ingredientsList | |
// Parsing keys with primitive assignments | |
// Access the placeOfOrigin key of the base object, store the value as String | |
// Access the image key of the base object, store the value as String | |
// Access the description key from the base object, store the value as String | |
} catch (JSONException e) { | |
/* Print Any Errors */ | |
e.printStackTrace(); | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment