Six Stars

tfileInputJSON and XPATH

I have a JSON file that contains
{"ORDER":"250"}

I would like to parse JSON with the use of XPATH. I use tFileIputJSON and logRow. What I have to do so that "250" will be shown with tLogRow.
I don't know what I have to put inside 'Loop Xpath query' and 'Xpath query' ?
10 REPLIES
One Star

Re: tfileInputJSON and XPATH

{"ORDER","250"} is not a json. Maybe you want to put {"ORDER":"250"}? If yes, you put just "/" in the 'Loop XPath query' and "ORDER" in 'XPath query'.
Lin LIN
Consultant BI/Talend
Synaltic Group
Six Stars

Re: tfileInputJSON and XPATH

It works but if I change JSON to
{"ORDER":{"seba":"250"}}

it doesn't work anymore, why so?
One Star

Re: tfileInputJSON and XPATH

Do you want to take "250" or "seba":"250"? If you want to take "250", you need to put "ORDER/seba" in "XPath query". Or "/Order" in "Loop XPath query" and "seba" in "XPath query".
Lin LIN
Consultant BI/Talend
Synaltic Group
Six Stars

Re: tfileInputJSON and XPATH

I would like to take {"seba":"250"}.
One Star

Re: tfileInputJSON and XPATH

If you want to take {"seba":"250"}, maybe you should use JsonPath. You put "$" in "Loop Json query" and "ORDER" in Json query.
Lin LIN
Consultant BI/Talend
Synaltic Group
Six Stars

Re: tfileInputJSON and XPATH

How should I get "seba":"250" ?
One Star

Re: tfileInputJSON and XPATH

I think you should use the component tReplace or you code in tJavaRow.
Lin LIN
Consultant BI/Talend
Synaltic Group
Six Stars

Re: tfileInputJSON and XPATH

So with XPATH I cannot get out {"seba":"250"} if my JSON file looks like {"ORDER":{"seba":"250"}} ? 
One Star

Re: tfileInputJSON and XPATH

No, you can't.
Lin LIN
Consultant BI/Talend
Synaltic Group
Six Stars

Re: tfileInputJSON and XPATH

No, you can't.

This is not true. This can be achieved with this setting: