Package com.teamdev.jxbrowser.js
Interface Json
public interface Json
A helper class that allows converting JavaScript objects into a JSON string and creating
JavaScript objects from a JSON string.
When the web page is unloaded, all the JavaScript objects will be automatically disposed.
Access to the already disposed JavaScript object will lead to the IllegalStateException
.
-
Method Summary
-
Method Details
-
parse
Creates an object that represents the result of parsing the given string in JSON format.- Type Parameters:
T
- one of the following types:java.lang.Boolean
,java.lang.Double
,java.lang.String
, orJsObject
- Parameters:
json
- a string in JSON format- Returns:
- the result of parsing. Can be
null
if the result of parsing isnull
. For example, when the given JSON string is "null", then the method returnsnull
- Throws:
JsException
- when an invalid JSON string is passedIllegalArgumentException
- whenjson
is empty or blank
-
stringify
Converts the given JavaScript object into a JSON string.- Parameters:
jsObject
- a JavaScript object to convert into a JSON string- Returns:
- a JSON representation of the given JavaScript object
- Throws:
JsException
- when the given JavaScript object cannot be converted to a JSON string. For example, when a circular reference is found in the given JavaScript object
-