Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

JSON Build Tool: Error when Object Key Starts With a Number

Mike_Olson
7 - Meteor

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_NameJSON_ValueString
StoreFlagship
Product.FirstApples
Product.SecondBeets
Product.ThirdCorn
Sales Rank.1stApples
Sales Rank.2ndBeets
Sales Rank.3rdCorn
Employees.CaptainAlice
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"]

}

}

 

2 REPLIES 2
Felipe_Ribeir0
16 - Nebula

Hi @Mike_Olson 

 

Unfortunately, Alteryx understand these numbers as reference to arrays when building JSON structures.

 

Sales Rank.1stApples
Sales Rank.2ndBeets
Sales Rank.3rdCorn

 

As a workaround, you can build some logic to replace the 1, 2, 3 for other characters, so you can cheat Alteryx.

 

Felipe_Ribeir0_0-1666803942096.png

 

{
"Store": "Flagship",
"Product": {
"First": "Apples",
"Second": "Beets",
"Third": "Corn"
},
"Sales Rank": {
"first": "Apples",
"second": "Beets",
"third": "Corn"
},
"Employees": {
"Captain": "Alice",
"first Mate": "Bob"
}
}

 

 

Mike_Olson
7 - Meteor

Thanks.  That's unfortunate.  I'll see what I can do in my program with Replace formulas and other text manipulation.

Labels