Thursday, July 9, 2020

How to convert json values to Map in java

If  we  have  String like this

{ "POLICY_URL":"privacy-policy-page",
  "LOGIN_URL":"login",
  "CONTACT_US_URL":"contact-us-page",
  "FAQ_URL":"faqs-page",
  "TERMS_AND_CONDITION_URL":"terms-and-condition-page" }  and  have  to  convert  it to  map,

  then  we  can  use below code ,

    public  Map<String, String> convertJsonStringToMap(String  stringValueThatWeWantToConvert) {
         HashMap<String, Object> map = new HashMap<String, String>();
         ObjectMapper mapper = new ObjectMapper();
         return  mapper.readValue(stringValueThatWeWantToConvert, new TypeReference<HashMap<String, String>>() {});
    }
   



Some interesting things to explore more

 Here  some  some  things  to  study  more ,     How Google Search works               https://developers.google.com/search/docs/fundamental...