09-18-2020 10:05 AM
Hi,
I am new to snaplogic and want to create a JSON structure from a CSV file.
CSV file data
“Name”,“AddressLine1”
“Test1234”,“122 Test St”
The structure i need is very specific like:
[
{
“attributes”: {
“Name”: [
{
“value”: “Test1234”
}
],
“Addresses”: [
{
“value”: {
“AddressLine1”: [
{
“value”: “122 Test St”
}
]
}
}]
}]
Can someone help with a sample pipeline to create Json from CSV data
09-19-2020 01:17 AM
Hi Parin,
I’m not sure if my assumptions are correct attributes are group of column names right? See sample pipeline
canvas03_2020_09_19.slp (10.4 KB)
09-19-2020 08:11 AM
Hi Alchemiz,
Thank you for the sample snap and your assumption is correct but this is not the exact structure that i am looking for.
The different records are part of same array like in case of fname.
I have attached a smaple json for mutiple records which i need to create.
Also is there a way we can use JSON Generator snap which can use csv file data and convert it into JSON as i looking for something more dynamic.SampleJSON.txt (1.9 KB)
09-20-2020 10:54 PM
@Parin
Use mapper snap and keep your desired structure. Only replace the hardcoded part with $ like below.Then use group by N and make group size 0 to make it as array
{
“attributes”: {
“Name”: [
{
“value”:$Name
}
],
“Addresses”: [
{
“value”: {
“AddressLine1”: [
{
“value”: $AddressLine1
}
],
“City”: [
{
“value”: “AVC”
}
],
“StateProvince”: [
{
“value”: “WV”
}
],
“Country”: [
{
“value”: “US”
}
],
“Zip5”: [
{
“value”: “25271”
}
],
“AddrBestFlag”: [
{
“value”: “Y”
}
],
“Zip4”: [
{
“value”: null
}
]
}
}
]
}
}
09-26-2020 08:27 AM
HI Supratim,
Yes the mapper snap will work.
Thanks,
Parin Shah