# How to convert a message to YAML data format

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

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

     { empname: 234, cards: [12344,2999,3333] }
    
  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.

     { empname: 234, cards: [12344,2999,3333] }
    
  4. Wire the TBD to set property node.

  5. Drop YAML node from the transformation section to the canvas .

  6. keep all the setting in YAML node as default.

  7. click Save.

  8. Wire the set property node to YAML 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.b[1].

TIP

msg.payload.b[1] allows to access the <b>b<b> field from the yaml object converted from string
  1. Wire the YAML 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 .

 2999