public class LazyJsonParser extends Object
Modifier and Type | Class and Description |
---|---|
static class |
LazyJsonParser.ReadOnlyJsonNode
Provides the same functionality that a true
JsonNode would, except that
the nodes may not be cast to their original mutable types, thereby protecting the
JSON data against modification. |
Constructor and Description |
---|
LazyJsonParser(String json) |
Modifier and Type | Method and Description |
---|---|
String |
getJson()
Returns the original JSON string.
|
String |
getTextAtPath(String... fieldNames)
Descends into the parsed JSON data by field names and extract the text value, if any, that is
provided at the specified sub-path.
|
LazyJsonParser.ReadOnlyJsonNode |
root()
Returns the root node of the parsed JSON as a
LazyJsonParser.ReadOnlyJsonNode . |
public LazyJsonParser(String json)
public String getJson()
public LazyJsonParser.ReadOnlyJsonNode root()
LazyJsonParser.ReadOnlyJsonNode
.LazyJsonParser.ReadOnlyJsonNode
.public String getTextAtPath(String... fieldNames)
{
"a" : {
"b" : 42,
"c" : {
"d" : "x",
"e" : true
}
}
}
Calling getTextAsPath("a", "b", "c", "d")
would return "x"
. However,
any other call would return null
, as it would refer to a path that does not exist
or that contains a value that is not text.
fieldNames
- the list of field names to descend intonull
if that location does not exist
or contains anything other than textCopyright © 2002-2019 Atlassian. All Rights Reserved.