Serializing and Deserializing JSON


Hi Guys,

I'm using a utility (JIRA Connector) from the Forge where its Update action accepts a JSON string as input parameter, so I was thinking to create a List structure with all fields require for the update then Serialize that list to JSON and assign it to the input parameter, but the required JSON has a specific format where you need and Update Tag and for each Field to be updated you need a Set tag as well so for example to update a field called "Description" you need to use this JSON format :

{"update":{"description": [{"set": "Bug in business logic "}]}}

and when I Copied this format and used "Add Structure from JSON" it created the attached Structure as shown below, with three lists so do you know how can I Use JSON Deserializer for this three lists to this description field as an example, so then i can use the same principle to update more than one field ?

   



Thanks Guys



Hi John,

You can create two local variables each with type set to DescriptionItem and Update. To use them you have to follow below steps.

  1. Use assign widget to assign required value to DescriptionItem local variable.
  2. Use ListAppend system action to append this local variable to Description attribute of Update local variable.
  3. Follow step 2 for each value you want to include in your json.
  4. Now serialize Update local variable to json and pass where ever you need.



 But how would this process know the corresponding Field name to have the required update value?

The JSON Structure to update to Fields "description" and summary is:

{"update":{"summary": [{"set": "Create New MPSW Tenant2"}]},"update":{"description": [{"set": "Bug in business logic 2"}]}}

so if I append the value of DescriptionItem to the Description attribute of Update local variable how would it know to add it to "description" field and how would it work it "Summary" field?

Thanks


And sorry don't how to assign a value to the Description attribute of a variable, or maybe you mean to assign it to the Description attribute of Update Structure (not variable)!, then serialize the Update Structure!?


Thanks  


{"update":{"summary": [{"set": "Create New MPSW Tenant2"}]},"update":{"description": [{"set": "Bug in business logic 2"}]}}

is this format correct? 


Filipe Silva wrote:

{"update":{"summary": [{"set": "Create New MPSW Tenant2"}]},"update":{"description": [{"set": "Bug in business logic 2"}]}}

is this format correct? 



Well when I sent this JSON format it works and updates both fields but when I remove one update or both updates tags, it does work.

also this format works, where you use update as common factor

{"update":{"summary": [{"set": "Create New MPSW Tenant1"}],"description": [{"set": "Bug in business logic 1"}]}}