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>>() {});
    }
   



The AI Driven Software Developer, Optimize Innovate Transform

  The AI-Driven Software Developer: Optimize, Innovate, Transform": AI Transformation in Software Development : Understand how AI is re...