public class

LazyJsonParser

extends Object
java.lang.Object
   ↳ com.atlassian.jira.entity.remotelink.LazyJsonParser

Class Overview

Lazy-loading JSON tree parser.

Summary

Nested Classes
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. 
Public Constructors
LazyJsonParser(String json)
Public Methods
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.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public LazyJsonParser (String json)

Public Methods

public String getJson ()

Returns the original JSON string.

Returns
  • the original JSON string.

public 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. For example, given the JSON content:


     {
         "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.

Parameters
fieldNames the list of field names to descend into
Returns
  • the text found at the specified location, or null if that location does not exist or contains anything other than text

public LazyJsonParser.ReadOnlyJsonNode root ()

Returns the root node of the parsed JSON as a LazyJsonParser.ReadOnlyJsonNode.

Returns