json parsing

Five Stars

json parsing

I am parsing json data which looks like this: { "guidelines": { "total": 4, "results" : [ { "Field_2": "AAA_222" "Field_3": "AAA_333" "Field_4": "AAA_444" }, { "Field_1": "BBB_111" "Field_2": "BBB_222" "Field_3": "BBB_333" "Field_4": "BBB_444" } ] } } When I parse this data with the tfileInputJSON component I get the following result: total Field_1 Field_2 Field_3 Field_4 4 BBB_111 AAA_222 AAA_333 AAA_444 4 null BBB_222 BBB_333 BBB_444 The "BBB_111" belongs on the second row, not the first. The parser is "rolling up" the values due to Field_1 not requiring a value in the first row. I used "JasonPath without Loop", "JasonPath" produced a similar effect, ie. there was no placeholder for the empty Field_1 value. Here's the JSONPath query: "$.guidelines.total" "$.guidelines.results[*].Field_1" "$.guidelines.results[*].Field_2" "$.guidelines.results[*].Field_3" "$.guidelines.results[*].Field_4" Can any advise on how I can get the parser to out put the data correctly with the value "BBB_111" on the second line and null on the first? Many thanks, Bob.

Tags (1)

Accepted Solutions
Eleven Stars

Re: json parsing

with Json , it worked in two steps TalendImage.JPGTalendImage3.JPG

Regards
Abhishek KUMAR

All Replies
Eleven Stars

Re: json parsing

Can you please attach Sample JSON .

 

Sorry Also can you please reformat your request , it is not easy to read.

Regards
Abhishek KUMAR
Highlighted
Five Stars

Re: json parsing

Not sure what happened there, but, I am parsing json data which looks like this:

 

{ "guidelines": {

    "total": 4,

    "results" : [

         {

              "Field_2": "AAA_222"

              "Field_3": "AAA_333"

              "Field_4": "AAA_444"

         },

         {

             "Field_1": "BBB_111"

             "Field_2": "BBB_222"

             "Field_3": "BBB_333"

             "Field_4": "BBB_444"

        }

        ]

    }

}

 

 

When I parse this data with the tfileInputJSON component I get the following result:

total  Field_1      Field_2      Field_3      Field_4

4       BBB_111  AAA_222   AAA_333   AAA_444

4       null            BBB_222   BBB_333   BBB_444

 

The "BBB_111" belongs on the second row, not the first. The parser is "rolling up" the values due to Field_1 not requiring a value in the first row. I used "JasonPath without Loop", "JasonPath" produced a similar effect, ie. there was no placeholder for the empty Field_1 value.

 

Here's the JSONPath query:

"$.guidelines.total"

"$.guidelines.results[*].Field_1"

"$.guidelines.results[*].Field_2"

"$.guidelines.results[*].Field_3"

"$.guidelines.results[*].Field_4"

 

Can any advise on how I can get the parser to out put the data correctly with the value "BBB_111" on the second line and null on the first?

Many thanks,

Bob.

Eleven Stars

Re: json parsing

I tried Xpath stuff , it worked for me 

 

TalendImage.JPG

Regards
Abhishek KUMAR
Five Stars

Re: json parsing

So it does!
Is this characteristic common to all json parsers, or a Talend "feature"
many thanks.
Eleven Stars

Re: json parsing

with Json , it worked in two steps TalendImage.JPGTalendImage3.JPG

Regards
Abhishek KUMAR
Five Stars

Re: json parsing

At last, got it to work.

Thank you!

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

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog