Jump to content

Component: JSON Encoder (Comms: IoT/Cloud): Difference between revisions

From Flowcode Help
m Text replacement - "width="90%" style="background-color:#D8C9D8; color:#4B008D;"" to "width="90%" class="mtx-class-macrohead""
 
(3 intermediate revisions by the same user not shown)
Line 44: Line 44:


===AssignDataAsFloat===
===AssignDataAsFloat===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AssignDataAsFloat'''
| width="90%" class="mtx-class-macrohead" | '''AssignDataAsFloat'''
|-
|-
| colspan="2" | Assigns a data value as a floating point value 
| colspan="2" | Assigns a data value as a floating point value 
Line 73: Line 73:


===AssignDataAsNumber===
===AssignDataAsNumber===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AssignDataAsNumber'''
| width="90%" class="mtx-class-macrohead" | '''AssignDataAsNumber'''
|-
|-
| colspan="2" | Assigns a data value as a integer value 
| colspan="2" | Assigns a data value as a integer value 
Line 97: Line 97:


===AssignDataAsString===
===AssignDataAsString===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AssignDataAsString'''
| width="90%" class="mtx-class-macrohead" | '''AssignDataAsString'''
|-
|-
| colspan="2" | Assigns a data value as a string 
| colspan="2" | Assigns a data value as a string 
Line 121: Line 121:


===AssignName===
===AssignName===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''AssignName'''
| width="90%" class="mtx-class-macrohead" | '''AssignName'''
|-
|-
| colspan="2" | Assigns a name value as a string. Call this macro first before assigning data to the element. 
| colspan="2" | Assigns a name value as a string. Call this macro first before assigning data to the element. 
Line 145: Line 145:


===ClearAll===
===ClearAll===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ClearAll'''
| width="90%" class="mtx-class-macrohead" | '''ClearAll'''
|-
|-
| colspan="2" | Clears all the names and data values out of the buffer 
| colspan="2" | Clears all the names and data values out of the buffer 
Line 159: Line 159:


===GenerateJSON===
===GenerateJSON===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GenerateJSON'''
| width="90%" class="mtx-class-macrohead" | '''GenerateJSON'''
|-
|-
| colspan="2" | Generates a JSON data string with the current specified values. 
| colspan="2" | Generates a JSON data string with the current specified values. 
Line 174: Line 174:
==Property reference==
==Property reference==


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
| width="90%" class="mtx-class-macrohead" | '''Properties'''  
|-
|-
|-
|-

Latest revision as of 14:23, 13 July 2026

Author Matrix TSL
Version 1.0
Category Comms: IoT/Cloud


JSON Encoder component

Allows dynamic key and value pairs to be created and assembled into a formatted JSON string.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_JSONEncoder.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_JSONEncoder.fcfx

Detailed description

No detailed description exists yet for this component

Examples

Simple Data

Example program showing how to use a JSON encoder component to create a simple JSON encoded data string.

JSON Encoder Example

Simple Encode and Decode

Example program showing how to take data and encode it into a JSON string to be sent out over comms.

The example also hows how to decode a received JSON string and pull out values.

JSON_Demo

Macro reference

AssignDataAsFloat

AssignDataAsFloat
Assigns a data value as a floating point value 
- UINT Element
Index of the element to assign the data to 
- FLOAT Data
 
- BYTE NumDP
Number of decimal points 
- VOID Return


AssignDataAsNumber

AssignDataAsNumber
Assigns a data value as a integer value 
- UINT Element
Index of the element to assign the data to 
- LONG Data
 
- VOID Return


AssignDataAsString

AssignDataAsString
Assigns a data value as a string 
- UINT Element
Index of the element to assign the data to 
- STRING Data
 
- VOID Return


AssignName

AssignName
Assigns a name value as a string. Call this macro first before assigning data to the element. 
- UINT Element
Index of the element to assign the data to 
- STRING Name
 
- VOID Return


ClearAll

ClearAll
Clears all the names and data values out of the buffer 
- VOID Return


GenerateJSON

GenerateJSON
Generates a JSON data string with the current specified values. 
- STRING Return


Property reference

Properties
Data Bytes
Number of bytes used to store the entire data for the JSON message. Includes names and data values so make sure this is large enough to store everything you want to be able to put into a single JSON data string.