Parse Nested JSON String | Technical Phone Interview
Anonymous User
6216

Small startup asked this question:

Given a JSON string and a list of strings, find all values in the JSON string corresponding to the keys given in the list of strings, and replace all numbers in the values with the '#' character.

e.g. {"user": {"age": "16 years", "name": "Bill Gates", "weight": "200 lbs", "height": "72 in"}, ["age", "height"]
output: {"user":{"age":"xx years", "name": "Bill Gates", "weight":"200 lbs", "height":"xx in"}

or more complicated case:
{"user":{"age":["16 years"], "name": "Bill Gates", "weight": {"weight": "200 lbs"}, "height":"72 in"}, ["age", "weight"]
output: {"user":{"age":["xx years"], "name": "Bill Gates", "weight": {"weight": "xxx lbs"}, "height":"72 in"}

Comments (6)