One Star

[resolved] How to convert JSON string with loop elements into another JSON format

Hi,
I have one JSON string like below:
{
        "taglist": ,
        "errcode": 0,
        "errmsg": "ok"
    }


As you see, taglist is an array. I want to convert this JSON string into another format like:
{
       "tags":
}

How to do it?
1 ACCEPTED SOLUTION

Accepted Solutions
One Star

Re: [resolved] How to convert JSON string with loop elements into another JSON format

Thank you , Lin.
After tried with a few scenarios, I feel tWriteJSONField is not feasible enough to cater for complex JSON format. I have changed to use tJSONDoc* component which are available in Exchange. 
5 REPLIES
One Star

Re: [resolved] How to convert JSON string with loop elements into another JSON format

One Star

Re: [resolved] How to convert JSON string with loop elements into another JSON format

I use these tools to validate and share json data Json Viewer and Json Formatter
One Star

Re: [resolved] How to convert JSON string with loop elements into another JSON format

Thanks, Lin.
This approach works for now. 
Because it relies on "Group by" feature on tWriteJSONField to output one single line, this approach only works for constant count. 
What to do if count has different value? E.g. 
{
       "tags":
}
One Star

Re: [resolved] How to convert JSON string with loop elements into another JSON format

Hello seanzhang1212,
You can just create a field 'bidon'(french) and you don't use it at the end. I take the same exemple, if the field 'bidon' is 'count', you delete just the link of the 'count' in the component tWriteJSONField. I hope that is understandable for you.
One Star

Re: [resolved] How to convert JSON string with loop elements into another JSON format

Thank you , Lin.
After tried with a few scenarios, I feel tWriteJSONField is not feasible enough to cater for complex JSON format. I have changed to use tJSONDoc* component which are available in Exchange.