0

I have my JSON data stored in JsonNode. Which is the most efficient way to search for a field in this JsonNode?

  1. JsonNode.findValue() or I should use Jsonpath .read()
  2. Is JsonNode.findValue() internally de marshalling JSON to POJOs for finding specified value.

Which way is better. Please help.

Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
  • The *fastest* way is probably using regex to match your target. – Bohemian Oct 24 '19 at 05:41
  • But one consideration is, I have data in JsonNode. JsonPath.read() requires input JSON to be a string . I need to convert my data to a string for using JsonPath.read(). Will using JsonPath.read() be still quicker ?? – anurag mishra Oct 24 '19 at 05:50
  • @anuragmishra - Converting back to string and then parsing again won't certainly NOT be the most efficient way. If you have JsonNode, you can create a simple tree traversal to search for a field in that JSON tree. Either way - If you want to find the most efficient, then simply try both and measure. – Ondra Žižka Sep 22 '22 at 14:17

0 Answers0