Package com.yahoo.text
Class JSON
java.lang.Object
com.yahoo.text.JSON
Static methods for working with JSON.
- Author:
- bratseth
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Outputs a map as a JSON 'object' string, provided that the map values are either String Number Any object whose toString returns JSONstatic boolean
Test whether two JSON strings are equal, e.g.static String
Returns the given string as a properly json escaped string
-
Method Details
-
encode
Outputs a map as a JSON 'object' string, provided that the map values are either- String
- Number
- Any object whose toString returns JSON
-
escape
Returns the given string as a properly json escaped string -
equals
Test whether two JSON strings are equal, e.g. the order of fields in an object is irrelevant.When comparing two numbers of the two JSON strings, the result is only guaranteed to be correct if (a) both are integers (without fraction and exponent) and each fits in a long, or (b) both are non-integers, fits in a double, and are syntactically identical. Examples of pairs that may not be equal: 1 and 1.0 (different types), 0.1 and 1e-1, 0.0 and 0.00.
- Throws:
RuntimeException
- on invalid JSON
-