com.dropbox.client2.jsonextract
Class JsonThing

java.lang.Object
  extended by com.dropbox.client2.jsonextract.JsonThing

public final class JsonThing
extends java.lang.Object

(Internal class for extracting JSON.)

A utility class to let you extract your required structure out of an org.json.simple object.

As you descend into the object and pull our your data, these classes keep track of where you are, so if there's an error in the JSON value, you'll get a "path" string describing exactly where the problem is.


Nested Class Summary
static class JsonThing.OptionalExtractor<T>
           
 
Field Summary
 T internal
           
 java.lang.String path
           
 
Constructor Summary
JsonThing(java.lang.Object internal)
           
JsonThing(java.lang.Object internal, java.lang.String path)
           
 
Method Summary
 JsonExtractionException error(java.lang.String message)
           
 boolean expectBoolean()
           
 long expectInt64()
           
 JsonList expectList()
           
 JsonMap expectMap()
           
 void expectNull()
           
 java.lang.Number expectNumber()
           
 java.lang.String expectString()
           
 java.lang.String expectStringOrNull()
           
 boolean isBoolean()
           
 boolean isInt64()
           
 boolean isList()
           
 boolean isMap()
           
 boolean isNull()
           
 boolean isNumber()
           
 boolean isString()
           
<T> T
optionalExtract(JsonExtractor<T> extractor)
           
 JsonExtractionException unexpected()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

internal

public final T internal

path

public final java.lang.String path
Constructor Detail

JsonThing

public JsonThing(java.lang.Object internal,
                 java.lang.String path)

JsonThing

public JsonThing(java.lang.Object internal)
Method Detail

expectNull

public void expectNull()
                throws JsonExtractionException
Throws:
JsonExtractionException

isNull

public boolean isNull()

expectMap

public JsonMap expectMap()
                  throws JsonExtractionException
Throws:
JsonExtractionException

isMap

public boolean isMap()

expectList

public JsonList expectList()
                    throws JsonExtractionException
Throws:
JsonExtractionException

isList

public boolean isList()

expectNumber

public java.lang.Number expectNumber()
                              throws JsonExtractionException
Throws:
JsonExtractionException

isNumber

public boolean isNumber()

expectInt64

public long expectInt64()
                 throws JsonExtractionException
Throws:
JsonExtractionException

isInt64

public boolean isInt64()

expectString

public java.lang.String expectString()
                              throws JsonExtractionException
Throws:
JsonExtractionException

expectStringOrNull

public java.lang.String expectStringOrNull()
                                    throws JsonExtractionException
Throws:
JsonExtractionException

isString

public boolean isString()

expectBoolean

public boolean expectBoolean()
                      throws JsonExtractionException
Throws:
JsonExtractionException

isBoolean

public boolean isBoolean()

unexpected

public JsonExtractionException unexpected()

optionalExtract

public <T> T optionalExtract(JsonExtractor<T> extractor)
                  throws JsonExtractionException
Throws:
JsonExtractionException

error

public JsonExtractionException error(java.lang.String message)