json parsing

Highlighted
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
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!

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Download