[英]How to get value from child jsonnode using java
I need to get codec value from jsonnode using java. 我需要使用Java从jsonnode获取编解码器值。 The following is the jsonnode with parent and child nodes. 以下是带有父节点和子节点的jsonnode。
{
"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. 它始终返回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? 如何使用Java从上述json获取编解码器值?
Kindly provide your inputs. 请提供您的输入。
You can use json expression "/DetectedProperties/codec" for this. 您可以为此使用json表达式“ / DetectedProperties / codec”。
JsonParser parser = new JsonFactory().createParser(getCodecInfo().toString());
parser.setCodec(new ObjectMapper());
TreeNode tree = parser.readValueAsTree();
System.out.println(tree.at("/DetectedProperties/codec"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.