public class BBJSONResolver
Utility class for extracting values from a JSON document given a dot-delimited path.
Modifier and Type | Method and Description |
---|---|
static BBjString | getValue(BBjString p_path$, BBjString p_jsonContent$) getValue
Given a dot-delimited JSON path and a JSON document as a string, traverses the JSON document
to extract the value. |
static com.fasterxml.jackson.databind.JsonNode | resolvePath(BBjString p_path$, JsonNode p_jsonNode!) resolvePath
Given a dot-delimited JSON path and a JSON document as a Jackson JSON document,
traverses the JSON document to extract the value. |
static com.fasterxml.jackson.databind.JsonNode | resolvePath(BBjString p_parentNodeName$, BBjString p_path$, JsonNode p_jsonNode!) Method called by the other utility methods. This method recursively resolves a JSON path given the name of the parent node, the current JSON path, and the current JsonNode. As this method calls itself, it builds the name of the parent node, passes in the remaining path, and passes in the descendant of the JsonNode. Though this method may be called directly, it's really intended to be invoked by the utility class's other methods. |
public static BBjString getValue(BBjString p_path$, BBjString p_jsonContent$)
getValue
Given a dot-delimited JSON path and a JSON document as a string, traverses the JSON document
to extract the value.
For example:
If I have the path "RestResponse.result[0].name" and my JSON document consists of
{ "RestResponse" : { "result" : [ { "name" : "Afghanistan" } ] } } ,
my result will be "Afghanistan".
p_path$
A dot-delimited JSON path specifying a value to extract from the JSON documentp_jsonContent$
A JSON document in string formpublic static com.fasterxml.jackson.databind.JsonNode resolvePath(BBjString p_path$, JsonNode p_jsonNode!)
resolvePath
Given a dot-delimited JSON path and a JSON document as a Jackson JSON document,
traverses the JSON document to extract the value.
For example:
If I have the path "RestResponse.result[0].name" and my JSON document consists of
{ "RestResponse" : { "result" : [ { "name" : "Afghanistan" } ] } } ,
my result will be a JsonNode object containing "Afghanistan".
p_path$
A dot-delimited JSON path specifying a value to extract from the JSON documentp_jsonNode$
A JSON document as a JsonNode objectpublic static com.fasterxml.jackson.databind.JsonNode resolvePath(BBjString p_parentNodeName$, BBjString p_path$, JsonNode p_jsonNode!)
Method called by the other utility methods. This method recursively resolves a JSON path given the name of the parent node, the current JSON path, and the current JsonNode. As this method calls itself, it builds the name of the parent node, passes in the remaining path, and passes in the descendant of the JsonNode. Though this method may be called directly, it's really intended to be invoked by the utility class's other methods.
p_parentNodeName$
The parent path of the JSON path being processedp_path$
A dot-delimited JSON path specifying a value to extract from the JSON documentp_jsonNode$
A JSON document as a JsonNode object