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

Five Stars

[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?

Accepted Solutions
Five Stars

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. 

All 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
Five Stars

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.
Five Stars

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. 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read