ArdoJSON

ArdoJSON (ODC)

Stable version 0.2.0 (Compatible with ODC)
Uploaded on 07 August 2024 by OutSystems Labs
ArdoJSON

ArdoJSON (ODC)

Documentation
0.2.0

How to use the "JSONSelect" action

The next steps will guide you on how to use this component. In the end, you should have an action that allows simple path selection of an element in the JSON.


1. Create a flow to retrieve the path of a JSON

Create a server action and call "JSONSelect" action, as can be seen in the picture below as a sample.


Fill the input parameter "JSONIn" with the JSON to process and the parameter "Path" with the path to retrieve.

You optionally enable set the "AlwaysReturnAsJSON" parameter to true to force the result to always be a valid JSON.
If set to false (default value), when the path string parse will result in a single element, instead of returning the result inclosed in double quotes (valid JSON), the result will not include the enclosing quotes.


Path expressions:

  • $    the root object/element
  • @    the current object/element
  • . or []    child operator
  • ..    recursive descent. JSONPath borrows this syntax from E4X.
  • *    wildcard. All objects/elements regardless of their names.
  • []    subscript operator. XPath uses it to iterate over element collections and for predicates. In Javascript and JSON it is the native array operator.
  • [,]    Union operator in XPath results in a combination of node sets. JSONPath allows alternate names or array indices as a set.
  • [start:end:step]    array slice operator borrowed from ES4.
  • ?()    applies a filter (script) expression.
  • ()    script expression, using the underlying script engine.

 See: JSONPath expressions - https://goessner.net/

See below an example



As a result of this transformation now you only have the JSON path selected.


How to use the "JSON_Listify" action

The next steps will guide you on how to use this component. In the end, you should have an action that allows the replacement of the original JSON into a JSON representation list of key/value pairs. It can be the entire JSON or just a portion specified by the Path.



1. Create a flow to retrieve the path of a JSON

Create a server action and call the "JSON_Listify" action, as can be seen in the picture below as a sample.



Fill the input parameter "JSONIn" with the JSON to process and the parameter "Path" with the path to retrieve ( for the Path expressions please refer to the "JSONSelect" documentation).


See below an example 



As a result of this transformation now you only have the original JSON with the attributes replaced as  "key/value" objects for the path selected.


How to use the "JSON_Objectify" action

The next steps will guide you on how to use this component. In the end, you should have an action that allows the replacement of the key/value attributes of the original JSON into JSON objects from those attributes. It can be the entire JSON or just a portion specified by the Path.


1. Create a flow to retrieve the path of a JSON

Create a server action and call the "JSON_Objectify" action, as can be seen in the picture below as a sample.


Fill the input parameter "JSONIn" with the JSON to process and the parameter "Path" with the path to retrieve ( for the Path expressions please refer to the "JSONSelect" documentation).


See below an example 

 

As a result of this transformation now you only have the original JSON with the attributes called "key" and "value" replaced as an object where the key is the object key, and the value is the object value for the path selected.