How to convert hashmap to JSON object in Java

前端 未结 29 2033
谎友^
谎友^ 2020-11-22 11:20

How to convert or cast hashmap to JSON object in Java, and again convert JSON object to JSON string?

29条回答
  •  遇见更好的自我
    2020-11-22 11:58

    You can use:

    new JSONObject(map);
    

    Caution: This will only work for a Map!

    Other functions you can get from its documentation
    http://stleary.github.io/JSON-java/index.html

提交回复
热议问题