tExtractJsonFields error

Hello,
I followed the steps from the example with facebook friends, but with a different json, but valid.
this are the errors that I receive:
statistics] connecting to socket on port 4033
connected
java.io.IOException: Illegal character: <g>
A JSONObject text must begin with '{' at character 1 of 1391433900
java.io.IOException: Illegal character: <g>
java.io.IOException: Illegal character: <s>
A JSONObject text must begin with '{' at character 1 of ENTER_LOC
thi is a long message for all the values from my json.
Please let me know if you have any ideea why I have this error.
(I am using talend for the first time.)
Thank you!
8 REPLIES
Community Manager

Re: tExtractJsonFields error

Can you please give us an example your json string?
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

Re: tExtractJsonFields error

so for me the "likes/data" is actually "events/params" , and "user/friends" is actually all json data "$."
I can send also print screen with my settings
Thanks you!
{
"sessionTimestamp":1391433900,
"accountId":"stage-local",
"events":,
"userId":"100006603450795",
"tracking":{
"accountId":"stage-local",
"created":1391434031,
"createdMicroTimestamp":1391434031.2963,
"type":"session",
"userId":100006603450795,
"sessionTimestamp":1391433900
}
}

Re: tExtractJsonFields error

As you can see, some keys from params might be missing, is that an issue?
Thank you!
Community Manager

Re: tExtractJsonFields error

If you read json data from a file, you don't need a tExtractJsonField component, only use a tFileInputJson and set the loop jsonpath query as "/events/params", and then you are able to extract all the values, see my screenshot. As a newbie, I would suggest you to create a json metadata follows the wizards step by step.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

Re: tExtractJsonFields error

so if I moved the columns from extract Json to input Json and removed the extractJson palette, it worked.
The question is, why for this sample works with a json file?
https://help.talend.com/search/all?query=tExtractJSONFields&content-lang=en?focusedCommentId=2864749...
Thank you!
Community Manager

Re: tExtractJsonFields error

Like the sample in the component manual, you can read the events node from the json file, and then extract the values from the events node with tExtractJsonField, see my screenshots, however, only with a tFileInputJson component is enough to read the data from the json file.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

Re: tExtractJsonFields error

yes, true, but this means that I wont have acces to the first level of keys (sessionId,tracking etc), in which events is part of it.
thank you!
Community Manager

Re: tExtractJsonFields error

If you read the first node of the json file with query path "$.", tFileInputJson do not return an normal json string, the result do not start with the syntax {, (you can test it by yourself, add a tLogRow after tFileInputJson to print the result on the console), that leads to the failure on tExtractJsonField, that's why you get the error "A JSONObject text must begin with '{' at character 1 of 1391433900" in your job.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business