# How to convert a message to JSON data format

In this tutorial we will be converting a valid json string in the message to javascript object.

  1. TDB Following is the input json string which we will be using in this use case.

     {
         "uid": 10,
         "name": "Tony",
         "address": "9, Strathfield, NSW"
     }
    
  2. Drag and drop set property node from the transformation section in the pallette. Double click the node to open the editor.

  3. Click Add button under rules and select Set . Configure the Set field value as msg.payload . Select String for the to field type and provide the following on value section of to field.

        {
        "uid": "10",
        "name": "Tony",
        "address": "9, Strathfield, NSW"
        }
    
  4. Wire the TBD to set property node.

  5. Drop JSON node from the transformation section to the canvas. Double click the csv node to open the editor.

  6. keep all the setting in JSON node as default. i.e Convert between JSON String & Object.

  7. click Save.

  8. Wire the set property node to JSON node.

  9. Drop the debug node to the end of the flow and name it as Completed. Double click and open the debug node editor and set the Output as msg.payload.address.

TIP

msg.payload.address allows to access the address field from the object converted from json string

  1. Wire the JSON node to debug node.

  2. Now click the TBD to test the flow.

Observation

On the debug panel on the final debug node (Completed) the following payload will be printed:

 9, Strathfield, NSW