// input1 - generic valid JSON string // input2 - colon separated JSON path Write a method to output the value of the json node based on json path (traverse into the json tree using the path) // nth token represents the json key (n-1) level down from the root Example input: "accountName:accountAddress:city"
Anonymous
My question was: "How do I differentiate between the different paths in input2?" In a JSON object, the colon separates the key and value pair. In this example, it also represented accessing a nested key-value pair. Example: "name" : {"firstName":"John", "lastName: "Smith"} Given the path "name:firstName", I would return "John". When splitting a string into tokens, you split the string at a specific delimiter (often a comma, or space) But in this problem, the colon was treated as the string delimiter, AND the character denoting nested key-value pairs. If my string path was "name:firstName:name" I would not be able to tell if the string should be parsed, "name:firstName, name" or "name, firstName:name" or "name, firstName, name" ...because the colon is used for multiple purposes. I merely wanted clarification on how to parse the string, and if we could use a different delimiter. Ms. Gao didn't understand my question however or ask me to rephrase, instead opting to slander my abilities and accuse me of lying about my skillset.
Check out your Company Bowl for anonymous work chats.