One Star

csv file to json output

Hi,
I have a csv file having structure like
id, latitude, longitude
1,lat1,long1
1,lat2,long2
2,lat1,long1
3,lat1,long1
1,lat3,long3
here id is vehicle id and latitude and longitude are the coordinates of the vehicle. I want to produce a json file having structure like
{
"geometry": {
"coordinates": ,


]
},
"properties":{
"id": "1"
}
}
{
"geometry": {
"coordinates":
]
},
"properties":{
"id": "2"
}
}
{
"geometry": {
"coordinates":
]
},
"properties":{
"id": "3"
}
}
I have completed most of the part, but the main issue i am facing is creation of following '2D' array of vehicle co-ordinates.
,


]
Any pointer will be a great help Smiley Happy.
Regards
Sagar
4 REPLIES
One Star

Re: csv file to json output

Can you tell what issue you are facing ?
I would probably use java/groovy Code comp. to create and format the Json model you are expecting.
Csv input ->filter rows based on id-> execute java code to create Json str->store temp result in buffer .
One Star

Re: csv file to json output

Hi,
Thanks for the response, basically i am using "tWriteJSONField" to create json objects.
it works good first time but when i tried to use it in chain all values other than o/p of first "tWriteJSONField" becomes "null".
pls find attached screen shot of the job.
One Star

Re: csv file to json output

forgot to attach screen shot Smiley Happy, pls find it.
One Star

Re: csv file to json output

Can you please share the screenshot for the XML tree for tWriteJSONField components?