I’m transforming CSV to Json and would like to have Json arrays in the output. But I’m not sure this can be done with the current version of Easy Data Transform. (I’m on 1.20.0 trial)
My question is: Can the desired output as described below be achieved somehow. I’ve looked but couldn’t find any way.
The csv has columns like:
“Phone1_Customer1”
“Phone2_Customer1”
“Phone1_Customer2”
“Phone2_Customer2”
The prefered output would be like this:
[{
“Customers”: [
{
PhoneNumbers: [“238798239854”, "3284723874]
},
{
PhoneNumbers: [“8247284872”]
}
]
}]
I tried to achieve this by renaming the columns like so:
“Phone1_Customer1” → “Customers.0.PhoneNumbers.0”
“Phone2_Customer1” → “Customers.0.PhoneNumbers.1”
“Phone1_Customer2” → “Customers.1.PhoneNumbers.0”
“Phone2_Customer2” → “Customers.1.PhoneNumbers.1”
Also tried this:
I tried to achieve this by renaming the columns like so:
“Phone1_Customer1” → “Customers[0].PhoneNumbers[0]”
“Phone2_Customer1” → “Customers[0].PhoneNumbers[1]”
“Phone1_Customer2” → “Customers[1].PhoneNumbers[0]”
“Phone2_Customer2” → “Customers[1].PhoneNumbers[1]”
And even tried using the same column name twice in tho hopes it would magically turn into an array:
“Phone1_Customer1” → “Customers.PhoneNumbers”
“Phone2_Customer1” → “Customers.PhoneNumbers”
“Phone1_Customer2” → “Customers.PhoneNumbers”
“Phone2_Customer2” → “Customers.PhoneNumbers”
Intuitively I went looking for an output type in the json output, where you can configure the column types. I was looking for some checkbox for arrays there…
You’d also have to denote the type of the items in the array. (although technically a json array can contain different types)
Could try something like how HTML forms work. When multiple columns have the same name the values are all pushed into an array. Only thing then is that you cannot control the order of the values inside the array. (maybe on column order)
That way there is no need for special characters, no risk of breaking existing transforms.
Only a checkbox in the json output column type. Columns with the same name do get in the same array.
Take the phonenumber example:
Customer.Phone, 'Phone1"
Customer.Phone, “Phone2”
results in {“Customer”: {“Phone”:[“Phone1”, “Phone2”]}}
This doesn’t work with nested properties though, because there is no way to tell two seperate customers apart (like the first example in the original question)
Then there is the Customer.0.Phone.0 and Customer.0.Phone.1 approach where these numbers represent arrays and the position in the array. Don’t know if this would break anything for existing transforms. (Not if you could provide an array checkbox somewhere within the json output settings)
I think this is the most easy to understand approach for most people. (I left the previous HTML thing in here for inspiration maybe)
Hello! I am also interested in this feature and, since it’s been almost 2 years since the last comment, I thought I would ask if you’ve had the chance to revisit it.