I got this question in the interview. Below are the constrains:

  1. It is coming from untrusted source (meaning validation of json is required)
  2. the key will always be string the value can be string or another key value pair.
  3. Sample input {'abc':{'d':'ef','r':'er'}} -- map.get("abc").get("d") should return "ef".
  4. No other type i.e. integer or boolean or array in the json
  5. Validation and parsing must in done simultaneously
  6. In case of invalid json string throw exception
Comments (8)