I need to get codec value from jsonnode using java. The following is the jsonnode with parent and child nodes.
{
"DetectedProperties":{
"Bitrate":262610704,
"FrameRate":"24/1",
"FileSize":32827252,
"Height":1080,
"Width":1920,
"DurationMillis":1.0,
"codec":"prores"
}
}
the the following code snipet doesn't return a value for codec. It always returns null.
JsonNode videoProperties = getCodecInfo(videoFile);
JsonNode videoInfo = videoProperties.get("DetectedProperties");
log.debug("codec: " + videoInfo.get("codec").toString()); // returns null
How to get the codec value from the above json using java?
Kindly provide your inputs.
You can use json expression "/DetectedProperties/codec" for this.
JsonParser parser = new JsonFactory().createParser(getCodecInfo().toString());
parser.setCodec(new ObjectMapper());
TreeNode tree = parser.readValueAsTree();
System.out.println(tree.at("/DetectedProperties/codec"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.