I got this question in the interview. Below are the constrains:
- It is coming from untrusted source (meaning validation of json is required)
- the key will always be string the value can be string or another key value pair.
- Sample input {'abc':{'d':'ef','r':'er'}} -- map.get("abc").get("d") should return "ef".
- No other type i.e. integer or boolean or array in the json
- Validation and parsing must in done simultaneously
- In case of invalid json string throw exception