Edison Edison - 1 year ago 88
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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download