JSON API

FLX provides a JSON API for manipulating and serialising JSON. The implementation is based on Google’s GSON. For instance, the JsonObject class referred in this documentation is a class from GSON library: JsonObject.

JSON Form Component

FLX provides a dedicated JSON form component for creating JSON objects.

JSON Editor

To edit a JSON form component value, FLX provides a dedicated JSON Editor Bottom Sheet:

  1. JSON Editor Bottom Sheet
  2. The text view for editing JSON.
  3. Ok Button is enabled only for valid JSON.
  4. Close Button to exit the bottom sheet without modifying the JSON.

JSON API Functions

Tests if the given form is a JsonArray.

  • form – an Any object

Returns: a Boolean value

Tests if the given form is a JsonElement.

  • form – an Anyobject

Returns: a Boolean value

Tests if the given form is a JsonObject.

  • form – an Anyobject

Returns: a Boolean value

Tests if the given form is a JsonPrimitive i.e. a wrapper for basic type value, such as, an Int, a Float, or a String.

  • form – an Anyobject

Returns: a Boolean value

Reads the content of the given file to a JsonObject. See the File API page.

  • file – a File

Returns: a JsonObject. If reading fails a Null is returned.

Converts the given jsonPrimitive to an Int. There are similar conversion functions for other primitive type values, e.g. (toFloatjsonPrimitive).

  • jsonPrimitive – a JSONPrimitive

Returns: An Int

Converts the given map collection object to JsonObject.

  • map – a Map

Returns: a JsonObject

Parses the given string to a JsonObject.

  • string – a valid JSON String

Returns: a JsonObject

Converts the given json to a Map.

  • json – a JsonObject

Returns: A Map

Gets the JSON value from the given httpResult object. See the HTTP API page.

  • httpResult – a HttpResultobject

Returns: a JsonObject

Write the given string to the given file. See the File API page.

  • file – a File specifying the output file
  • string – a String to be written

Returns: a Boolean indicating if file writing succeeded.