โ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