How to convert hashmap to JSON object in Java

前端 未结 29 2433
谎友^
谎友^ 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:47

    If you need use it in the code.

    Gson gsone = new Gson();
    JsonObject res = gsone.toJsonTree(sqlParams).getAsJsonObject();
    

提交回复
热议问题