Package ucar.unidata.util
Class Json
java.lang.Object
ucar.unidata.util.Json
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleandefault quote valuestatic final String_more_static final String_more_static final String_more_static final String_more_static final String_more_static final String_more_static final String_more_static final String_more_static final StringJSON MIME typestatic final Stringthe null string identifier -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddGeolocation(Appendable pw, double lat, double lon, double elevation) _more_static String_more_static String_more_static StringCreate a JSON object attributestatic StringCreate a JSON object attributestatic voidMake an attribute and add it to the liststatic StringcleanString(String aText) Clean a string of illegal JSON charactersstatic StringformatNumber(double d) _more_static StringGet a stringstatic StringCreate a JSON list from the array of stringsstatic StringCreate a JSON list from the array of stringsstatic StringCreate a JSON list from the array of stringsstatic String_more_static StringlistOpen()_more_static void_more_static StringCreate a JSON mapstatic StringCreate a JSON mapstatic StringCreate a JSON mapstatic StringCreate a JSON mapstatic StringmapAndQuote(String... values) Create a JSON mapstatic StringmapAndQuote(List<String> values) _more_static StringmapClose()_more_static String_more_static StringmapOpen()_more_static StringQuote a stringstatic voidquote the attribute value and add it to the liststatic StringtfoList(List<TwoFacedObject> values) Create a list of JSON object from a list of TwoFacedObjectsstatic StringtfoList(List<TwoFacedObject> values, String idKey, String labelKey) Create a list of JSON object from a list of TwoFacedObjects
-
Field Details
-
MIMETYPE
JSON MIME type- See Also:
-
NULL
the null string identifier- See Also:
-
DFLT_QUOTE
public static final boolean DFLT_QUOTEdefault quote value- See Also:
-
FIELD_NAME
_more_- See Also:
-
FIELD_FIELDS
_more_- See Also:
-
FIELD_DATA
_more_- See Also:
-
FIELD_VALUES
_more_- See Also:
-
FIELD_LATITUDE
_more_- See Also:
-
FIELD_LONGITUDE
_more_- See Also:
-
FIELD_ELEVATION
_more_- See Also:
-
FIELD_DATE
_more_- See Also:
-
-
Constructor Details
-
Json
public Json()
-
-
Method Details
-
addGeolocation
public static void addGeolocation(Appendable pw, double lat, double lon, double elevation) throws Exception _more_- Parameters:
pw- _more_lat- _more_lon- _more_elevation- _more_- Throws:
Exception- _more_
-
mapAndQuote
Create a JSON map- Parameters:
values- key/value pairs { key1,value1,key2,value2 }- Returns:
- the map object { key1:value1, key2:value2 }
-
map
Create a JSON map- Parameters:
values- key/value pairs { key1,value1,key2,value2 }- Returns:
- the map object { key1:value1, key2:value2 }
-
map
Create a JSON map- Parameters:
values- key/value pairs [ key1,value1,key2,value2 ]- Returns:
- the map object { key1:value1, key2:value2 }
-
mapAndQuote
_more_- Parameters:
values- _more_- Returns:
- _more_
-
map
Create a JSON map- Parameters:
values- key/value pairs { key1,value1,key2,value2 }quoteValue- true to quote the values- Returns:
- the map object { key1:value1, key2:value2 }
-
map
Create a JSON map- Parameters:
values- key/value pairs [ key1,value1,key2,value2 ]quoteValue- true to quote the values- Returns:
- the map object { key1:value1, key2:value2 }
-
list
Create a JSON list from the array of strings- Parameters:
values- list of values { value1,value2,value3,value4 }- Returns:
- the values as a JSON array [ value1,value2,value3,value4 ]
-
list
Create a JSON list from the array of strings- Parameters:
values- list of values [ value1,value2,value3,value4 ]- Returns:
- the values as a JSON array [ value1,value2,value3,value4 ]
-
mapKey
_more_- Parameters:
key- _more_- Returns:
- _more_
-
mapOpen
_more_- Returns:
- _more_
-
mapClose
_more_- Returns:
- _more_
-
listOpen
_more_- Returns:
- _more_
-
listClose
_more_- Returns:
- _more_
-
list
Create a JSON list from the array of strings- Parameters:
values- list of values [ value1,value2,value3,value4 ]quoteValue- true to quote the values- Returns:
- the values as a JSON array [ value1,value2,value3,value4 ]
-
tfoList
Create a list of JSON object from a list of TwoFacedObjects- Parameters:
values- the values- Returns:
- the list [ {id:id1,label:label1},{id:id2,label:label2} ]
-
tfoList
Create a list of JSON object from a list of TwoFacedObjects- Parameters:
values- the valuesidKey- the key for the TwoFacedObject IDlabelKey- the key for the TwoFacedObject label- Returns:
- the list [ {id:id1,label:label1},{id:id2,label:label2} ]
-
getString
Get a string- Parameters:
s- the stringquote- true to quote- Returns:
- the string
-
attr
_more_- Parameters:
name- _more_value- _more_- Returns:
- _more_
-
attr
_more_- Parameters:
name- _more_value- _more_- Returns:
- _more_
-
attr
Create a JSON object attribute- Parameters:
name- the attribute namevalue- the attribute value- Returns:
- the attribute as name:value
-
attr
Create a JSON object attribute- Parameters:
name- the attribute namevalue- the attribute valuequoteValue- true to quote the name and value- Returns:
- the attribute as name:value
-
quoteAttr
quote the attribute value and add it to the list- Parameters:
items- the list of itemsname- the attribute namevalue- the attribute value
-
attr
Make an attribute and add it to the list- Parameters:
items- the list of name/value pairsname- the attribute namevalue- the attribute value
-
formatNumber
_more_- Parameters:
d- _more_- Returns:
- _more_
-
quote
Quote a string- Parameters:
s- the string- Returns:
- the quoted string
-
cleanString
Clean a string of illegal JSON characters- Parameters:
aText- the string- Returns:
- the cleaned string
-
main
_more_- Parameters:
args- _more_
-