com.atlassian.jira.entity.remotelink
Class LazyJsonParser

java.lang.Object
  extended by com.atlassian.jira.entity.remotelink.LazyJsonParser

public class LazyJsonParser
extends Object

Lazy-loading JSON tree parser.

Since:
v6.1.1

Nested Class Summary
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 Summary
LazyJsonParser(String json)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LazyJsonParser

public LazyJsonParser(String json)
Method Detail

getJson

public String getJson()
Returns the original JSON string.

Returns:
the original JSON string.

root

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

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

getTextAtPath

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


Copyright © 2002-2014 Atlassian. All Rights Reserved.