Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Streaming data to JSON File!

Hello, so I am streaming some json data into a txt file. I later read the data from the text file using a tFileInputJSON in order to read only all the json objects inside a json array which is inside a json object and I pass this to a tFileOutputJSON. This process works however when I do so, I get some special character for "/". That is when a string contains "/" in the json data that is being streamed into the text, when I read the json data from the tFileOutputJson, i get "\/". How can I fix this?!!

 

Here is a better illustration:

The data streaming in is of the form:

{

"r": {

         "s": [ {"Level":3,

                      "url": "https://google.com",

                      "text": "hello world",

                      "Class": 3

                    },

                    {....

                    }]

  }

}

 

Essentially I only want the data inside the json array "s". So, in my tFileInputJSON, I read the text file which the json data was streamed to and I run the Loop json query as: "$.r.s[*]"

and I am able to get the required data and send it to tFileOutputJson. However, when I look at the text in tFileOutputJson, I get the following:

 

[ {"Level":3,

    "url": "https:\/\/google.com",

    "text": "hello world",

},

{....

}]

So if looking at the url value, I get "\/\/" instead of "//". How can I fix this?!! and why is this happening?

 

Also if you look at the json data I am trying to stream in, there is key named: "Class" that I also want to take in. I defined it in my schema when linking the tFileInputJson to tFileOutputJson, however, I get an error saying "Class" is a reserved Java keyword. Then, how can I pass the "Class": into my tFileOutputJson?

Labels (4)
1 Reply
Anonymous
Not applicable
Author

Hi sai06kiran 

 

I read the input data and print the URL on the console, I can see the value is right. Can you use a tLogRow after tFileInputJson to see if the value is extracted correctly?

0683p000009M1vQ.png

Talend Studio is a Java code generator, class is a reserved word in Java, so it can not be a column name.