Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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.

Labels (3)
1 Solution

Accepted Solutions
akumar2301
Specialist II
Specialist II

with Json , it worked in two steps 0683p000009M3ub.jpg0683p000009M42d.jpg

View solution in original post

6 Replies
akumar2301
Specialist II
Specialist II

Can you please attach Sample JSON .

 

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

Anonymous
Not applicable
Author

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.

akumar2301
Specialist II
Specialist II

I tried Xpath stuff , it worked for me 

 

0683p000009M42O.jpg

Anonymous
Not applicable
Author

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

with Json , it worked in two steps 0683p000009M3ub.jpg0683p000009M42d.jpg

Anonymous
Not applicable
Author

At last, got it to work.

Thank you!