Edison Edison - 5 months ago 34
JSON Question

Jackson read value as string

I have an object with unknown values, say

"data": [

And I just want to store the value of "data" as a string into a variable/database.

How should I read it from the streaming API?


Provided that you have already read this object into JsonNode, you can do it like this:

String content = jsonNode.get("data").textValue();

UPD: since you're using a streaming parser, this example on Jackson usage might help.

UPD: the method name is now textValue() - docs