Streaming data to JSON File!

Six Stars

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?

Community Manager

Re: Streaming data to JSON File!

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?

1.png

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

----------------------------------------------------------
Talend | Data Agility for Modern Business

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Why Companies Move to the Cloud: 7 Success Stories

Learn how and why companies are moving to the Cloud

Read Now

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch