is it possible to proccess JSON responses with the JDK or HttpComponents only?

后端 未结 3 1547
抹茶落季
抹茶落季 2020-12-02 01:30

we are upgrading our web app to use Facebook\'s Graph API, which returns JSON responses. However we don\'t want to add dependecy to a JSON library unless we have no other ch

3条回答
  •  借酒劲吻你
    2020-12-02 01:35

    It is possible. Because JSON is valid JavaScript syntax, you can use the built-in JavaScript interpreter via the scripting API to create and object graph, walk that (using the visitor pattern to push data into a Java object, for example).

    However, you need to trust the data or you leave yourself open to code injection attacks. To me, this would not be an adequate substitute for a proper JSON parser.

提交回复
热议问题