Skip to content

Martini JSON Functions

Martini's JSON functions are designed to facilitate the interaction between JSON text and Martini objects. These functions enable developers to efficiently convert JSON text to Martini objects and vice versa, streamlining data manipulation within services.

Utilization in Martini Services

Function Accessibility

While Java and Groovy offer native JSON manipulation methods, Martini's JSON functions are tailored for service-level operations within the Martini environment. These specialized functions provide a more integrated and efficient approach to handling JSON data.

Locating Functions

Access the JSON functions through the Martini Navigator. They are organized within the 'json' folder under the functions node, ensuring easy identification and access.

Applying Functions in Services

To employ a JSON function in a service, you can either:

  1. Drag and Drop: Select and drag the desired function from the navigator into your service.
  2. Content Assist: Use the content assist feature by pressing the dot (.) key. Type "Json." to view available functions, or enter the function name directly.

Example Use Case: Converting JSON String to Data Model

Objective

Convert a JSON string into a Martini data model object within a service.

Steps

  1. Function Selection: Identify a function capable of transforming a JSON string into a data model object.
  2. Data Model Declaration: In your service, declare a data model for the function's output. This could be named, for instance, "outputModel."
  3. Handling Unknown Properties: Set the “allow extra properties” option to “true.” This allows Martini to automatically manage any unrecognized properties in the JSON string.
  4. Input and Conversion: Provide the JSON text to the chosen function. Martini will convert this text into the data model format specified.
  5. Mapping and Output: Link the function's output to the declared data model in your service.
  6. Service Execution: Run the service to convert the JSON string into the data model object.

Result

Executing the service converts the JSON string into a Martini data model object, demonstrating the functionality of JSON functions in data conversion and manipulation within Martini services.