0

Lua to JSON

Description

The Lua to JSON part allows you to convert data between Lua and JSON data formats. You can use it to convert text strings from a Lua data format to a JSON format and vice versa. This part also has a parameter that allows you to format the JSON output so it is easier to read.

Node Type: This part is located in process nodes under the Misc category.

Used With: This part can be used with all framework-based projects as well as with projects that do not use a framework.

Editor Fields

Field Name Description/Use Type/Options Optional/Mandatory
Mode This is the direction of the conversion. Lua to JSON | 
JSON to Lua
Mandatory
Input path This is the name of the data object containing either Lua or JSON data.

If this is a collection of data strings, set Batch to 'yes'.
Data Object Mandatory
Output path This is the data object where the result will be stored. Data Object Mandatory
Batch If this is set to 'yes', the system treats the input path as a collection of formatted data, converting each element and storing the results in the output path. Yes | No Optional
Boolean Support When converting from LUA to JSON, select Yes to turn on support for Boolean values (variables set to true, false, and null are all converted correctly into corresponding JSON objects). Yes | No Optional
False value (default nil)

(Before Release 7.4)
Prior to Release 7.4, LogicNets does not automatically convert Booleans from JSON to LUA format. Therefore, a Boolean in JSON is converted into a LUA data object with the following override.
- A Boolean with the value true is converted to 1.
- A Boolean with the value false is converted to nil by default. This means that the variable is not available/saved in the LogicNets context. 

If you want the variable to be available in LogicNets, you can specify the value manually in this field.
Text Optional
Beautify output If you are using the Lua to JSON option the system will display this checkbox. If this checkbox is checked the system will format the JSON output so it is more easily readable. Checkbox Optional

Example

Download and import the following example projects in your workspace. 

Reply

null

Content aside

  • 5 yrs agoLast active
  • 251Views
  • 3 Following