Package ucar.unidata.util
Class Json
java.lang.Object
ucar.unidata.util.Json
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
default 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 String
JSON MIME typestatic final String
the null string identifier -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addGeolocation
(Appendable pw, double lat, double lon, double elevation) _more_static String
_more_static String
_more_static String
Create a JSON object attributestatic String
Create a JSON object attributestatic void
Make an attribute and add it to the liststatic String
cleanString
(String aText) Clean a string of illegal JSON charactersstatic String
formatNumber
(double d) _more_static String
Get a stringstatic String
Create a JSON list from the array of stringsstatic String
Create a JSON list from the array of stringsstatic String
Create a JSON list from the array of stringsstatic String
_more_static String
listOpen()
_more_static void
_more_static String
Create a JSON mapstatic String
Create a JSON mapstatic String
Create a JSON mapstatic String
Create a JSON mapstatic String
mapAndQuote
(String... values) Create a JSON mapstatic String
mapAndQuote
(List<String> values) _more_static String
mapClose()
_more_static String
_more_static String
mapOpen()
_more_static String
Quote a stringstatic void
quote the attribute value and add it to the liststatic String
tfoList
(List<TwoFacedObject> values) Create a list of JSON object from a list of TwoFacedObjectsstatic String
tfoList
(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_
-