I have a JSON schema where some object keys start with a number. The JSON Parse tool reads them as I would expect for Alteryx, but when using the JSON Build tool (using the results of the parse) it outputs them as an array rather than as an object with keys.
Additionally, when the object contains keys that start with a number and a character, this causes malformed JSON output (missing key value).
Is there an easy work-around for this, or will I just have to build my JSON manually using the Formula tool? Any advice is appreciated, thanks.
Sample JSON Input:
{
"Store":"Flagship",
"Product":{
"First":"Apples",
"Second":"Beets",
"Third":"Corn"
},
"Sales Rank":{
"1st":"Apples",
"2nd":"Beets",
"3rd":"Corn"
},
"Employees":{
"Captain":"Alice",
"1st Mate":"Bob"
}
}
JSON Parse Tool Output:
JSON_Name | JSON_ValueString |
Store | Flagship |
Product.First | Apples |
Product.Second | Beets |
Product.Third | Corn |
Sales Rank.1st | Apples |
Sales Rank.2nd | Beets |
Sales Rank.3rd | Corn |
Employees.Captain | Alice |
Employees.1st Mate | Bob |
JSON Build Output (new lines added for clarity):
{
"Store":"Flagship",
"Product":{
"First":"Apples",
"Second":"Beets",
"Third":"Corn"
},
"Sales Rank":
["Apples",
"Beets",
"Corn"],
"Employees":
{
"Captain":"Alice",
["Bob"]
}
}
Solved! Go to Solution.
Hi @Mike_Olson
Unfortunately, Alteryx understand these numbers as reference to arrays when building JSON structures.
Sales Rank.1st | Apples |
Sales Rank.2nd | Beets |
Sales Rank.3rd | Corn |
As a workaround, you can build some logic to replace the 1, 2, 3 for other characters, so you can cheat Alteryx.
{
"Store": "Flagship",
"Product": {
"First": "Apples",
"Second": "Beets",
"Third": "Corn"
},
"Sales Rank": {
"first": "Apples",
"second": "Beets",
"third": "Corn"
},
"Employees": {
"Captain": "Alice",
"first Mate": "Bob"
}
}
Thanks. That's unfortunate. I'll see what I can do in my program with Replace formulas and other text manipulation.