English
Fx.json
About 266 wordsLess than 1 minute
2026-01-09
1. toJson Convert object to JSON string
Convert object to JSON string
Fx.json.toJson(<Object data>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| data | Object | Object to be converted to JSON | Y |
Code examples
Fx.json.toJson(["a" : 1, "b" : 2]) // Returns: {"a":1,"b":2}2. toJson Convert object to JSON string with specified serialization features
Convert objects to JSON strings with specified serialization features
Fx.json.toJson(<Object data>, <SerializerFeature[] features>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| data | Object | The object to be converted to JSON | Y |
| features | SerializerFeature[] | Variable arguments, list of serialization features | -- |
Code examples
Map m = ["a": 1, "b": null]
log.info(Fx.json.toJson(m))
log.info(Fx.json.toJson(m, SerializerFeature.WriteMapNullValue))3. parse JSON to Map
Convert JSON to Map
Fx.json.parse(<String data>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| data | String | JSON string | Y |
Code examples
Map map = Fx.json.parse("{\"a\" : 1, \"b\" : 2}")4. parseList Convert JSON to List
Convert JSON to List
Fx.json.parseList(<String data>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| data | String | JSON array string | Y |
Code examples
List list = Fx.json.parseList('[{"a": 1, "b": 2},{"a": 10, "b": 20}]')Notice
- The string here is a JSON array string, starting with "[" and ending with "]"
5. parseObject JSON to class conversion
Convert JSON to Class
Fx.json.parseObject(<String text>, <Class clazz>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| text | String | JSON string | Y |
| clazz | Class | Target type for conversion, e.g. List.class | Y |
Code examples
List tmp = Fx.json.parseObject('[{"a": 1, "b": 2},{"a": 10, "b": 20}]', List.class)