tFileOutputJSON inserting new line "\" characters

Five Stars

tFileOutputJSON inserting new line "\" characters

I am trying to use the tfileoutputjson component but it is inserting new line characters in the file which means I can't use a json path query to extract the fields I need.

 

My flow is trestclient ---- tfileoutputjson. The json is formatted as expected when I use tlogrow. Any ideas how I prevent the "\n" being inserted in the output file?

 

Moderator

Re: tFileOutputJSON inserting new line "\" characters

Hello,

Could you please elaborate your case with an example with input and expected output values?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: tFileOutputJSON inserting new line "\" characters

Yes, sure. I am using the Google Places api and am expecting to receive a response in the following format:

 

{
    "html_attributions": [],
    "results": [
        {
            "formatted_address": "London, United Kingdom",
            "geometry": {
                "location": {
                    "lat": 0.5153788,
                    "lng": -0.1392263
                },
                "viewport": {
                    "northeast": {
                        "lat": 0.52708884999999,
                        "lng": -0.13778035
                    },
                    "southwest": {
                        "lat": 0.51147545000001,
                        "lng": -0.14356415
                    }
                }
            },
            "icon": "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
            "id": "c1942d9a94bad7dd667149b40786f0a0f6bd6769",
            "name": "Company Name",
            "place_id": "Place_id",
            "rating": 5,
            "reference": "example",
            "types": [
                "point_of_interest",
                "establishment"
            ]
        }
    ],
    "status": "OK"
}

But what I actually get back is in this format

 

{"data":[{"string":"{\n   \"html_attributions\" : [],\n   \"results\" : [\n      {\n         \"formatted_address\" : \"London, United Kingdom\",\n         \"geometry\" : {\n            \"location\" : {\n               \"lat\" : 0.5153788,\n               \"lng\" : -0.1392263\n            },\n            \"viewport\" : {\n               \"northeast\" : {\n                  \"lat\" : 0.52708884999999,\n                  \"lng\" : -0.13778035\n               },\n               \"southwest\" : {\n                  \"lat\" : 0.51147545000001,\n                  \"lng\" : -0.14356415\n               }\n            }\n         },\n         \"icon\" : \"https:\/\/maps.gstatic.com\/mapfiles\/place_api\/icons\/generic_business-71.png\",\n         \"id\" : \"c1942d9a94bad7dd667149b40786f0a0f6bd6769\",\n         \"name\" : \"DataXu\",\n         \"place_id\" : \"place_id",\n         \"rating\" : 5,\n         \"reference\" : \"CmRRAAAADMfvTkEkMvnLOOa-WXca3olzFgUz9d17pkzsD4bfxkU_-c9lE63nWsGj8YZJLH7p6BMRWyOmKhYWX35pioAN1Q-doaO-caPt-KuVI_wEhtOiSmXACU6ry_WwqCu1X8DVEhDkPbQfutBaWY7K0FHFwajUGhT6wziXwKWKZqGgOZ0D3dJL95bk6g\",\n         \"types\" : [ \"point_of_interest\", \"establishment\" ]\n      }\n   ],\n   \"status\" : \"OK\"\n}\n","body":null,"statusCode":200}]}

This is my  flow. 

TalendFlow.PNG

In tFileInputJSON I am trying to retrieve the place_id from the json file using the jsonpath query displayed, but because of the file format it is not working. 

 

TalendFlow02.PNG

Thanks

Five Stars

Re: tFileOutputJSON inserting new line "\" characters

Any advice on this one?

Three Stars

Re: tFileOutputJSON inserting new line "\" characters

I have the same problem!

It's like the component tries to stringify every fields and every value.

 

Anyone can help us?

Two Stars

Re: tFileOutputJSON inserting new line "\" characters

I think your webservice is returning wrong data, as talend json outpout properly works , even it's not indented.

Four Stars

Re: tFileOutputJSON inserting new line "\" characters

Any answer on this? I have the same issue and it's not the web service as it looks fine in the tLogRow directly before the tFileOutputJSON 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

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

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch