Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

getting arrays from the nulls in strings and nulls in integer values tWriteJSONField

Hello All

 

Am writing to JSON file from CSV, in that process see the below json file how it is generated 

 

"object": {
"number": "1548364482",  
"ID": "378827052",
"name": [],  (string datatype)
"ChainNumber": [],  (integer datatype)

"dispenserTypeCode": "1"

 

 

For the above string and integer data types i don't have any data  in my CSV which are null

 

So my expected output is below

 

"object": {
"number": "1548364482",
"ID": "378827052",
"name": "",  (string datatype)
"ChainNumber": null, ( for integer datatype)

"dispenserTypeCode": "1"

 

 

Can any one help me how to configure the twritejsonfeilds to get this kind of output

 

Thanks In Advance

Manish

Labels (3)
5 Replies
Anonymous
Not applicable
Author

Hi Manish,

 

    What about your input data? Is it an array for these problematic columns? Could you please share 5 input sample records so that we will get more idea?

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

Anonymous
Not applicable
Author

@nthampi Thanks

 

My input data is below, if we don't have a data while getting from csv and writing to json am not getting empty strings, rather getting empty arrays for string and integer like this [], [] , []

 

Boolean string string int
FALSE No Generic 1
FALSE Non Generic 2
       
FALSE None Generic 4

 

 

Thanks

Manish

Anonymous
Not applicable
Author

Hi Manish,

 

    Your input and output data looks totally different in your previous posts. Lets start again on a clean slate. Could you please provide 5 input records and corresponding JSON output in expected and actual cases?

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

Anonymous
Not applicable
Author

Thanks @nthampi 

 

The above below is the input csv

 

Boolean string string int
FALSE No Generic 1
FALSE Non Generic 2
       
FALSE None Generic 4

 

 

And the Json am getting is like below

 

"json": [

{

"Boolean" :false,

"string" :"no",

"string": "generic",

"int":1

},

{

"Boolean" :false,

"string" :"non",

"string": "generic",

"int":2

},

{

"Boolean" :[],

"string" : [],

"string": [],

"int":[]

},

{

"Boolean" :false,

"string" :"none",

"string": "generic",

"int":4

}

 

 

 

Please look at the red highlighted one, how would i rectify that

 

 

that highlighted red is expected in this format

 

{

"Boolean" :  ,

"string" :"",

"string": "",

"int":null

}

 

 

Thanks

Manish

Anonymous
Not applicable
Author

Hi Manish,

 

      There seems to be some problem in the input JSON you have provided. I would recommend to test it with JSONLint or some other tool. 

 

      Coming to the issue, you are trying to load a Boolean and integer value with empty string. The concept about boolean is that if true value is not available, by default, it will become false. So you will have to either provide true or false value. The best chance in your case will be to convert all the columns to String and then do the JSON conversion.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved