Query JSON / JSONATA not returning information

I have a very simple JSON object in a text column:

{“out-0”:“Who is the king of Belgium? The current king of Belgium is King Philippe. He was born on April 15, 1960, and is the eldest son of King Albert II and Queen Paola. As King, he serves as the General of the Belgian army and has also been involved in promoting Belgian companies and establishing business relations with other countries.”}

When I do Query JSON Column on this with out-0 as the JSONata query it doesn’t return anything.

When I try the following Javascript it also doesn’t do anything:
// Parse the JSON string into a JSON object
const jsonObject = JSON.parse(p1);

// Extract the value associated with the key “out-0”
const result = jsonObject[‘out-0’];

// Now, ‘result’ contains the value you’re interested in

When I do an Excel formula it works, however I assume this will only work for very simple JSON objects.

Excel Formula: MID(A1, LEN(“{”“out-0"”:“”“) + 1, LEN(A1) - LEN(”{““out-0"”:”“”) - LEN(“”“}”))

Any idea on why the JSONata is not working on my JSON object?
btw I tried different types of columns including the single row and also different jsonata queries such as: [‘out-0’]

Many thanks!

Tim

Hola Tim!

I think your dash/hyphen “-” is confusing the expression. JSONata thinks it’s a subtraction expression :wink:

Try with:

  **."out-0"

Saludos!

`out-0`

should be enough.

JSONata treats white space and dashes as special characters, so when you have them as keys on a root level field, you can bind them to ` characters to escape it.

1 Like

ufffs… my hat doesn’t have that rabbit! :grinning:

btw… how are these symbols ( `` ) called in English? … the Spanish language doesn’t have them.

Thanks!

A backtick or backquote, I believe.

1 Like

thanks @gvalero and @ThinhDinh

I was trying ‘out-0’ as well but that didn’t work.
However with the out-0 “backtick quotes” and with the solution of gustavo it works.
However i have no idea where to find these backtick quotes on my Belgium Azerty keyboard :sweat_smile:

It’s left to the number 1 key on my MacOS keyboard. I use a standard one.

no way… an AZERTY keyboard??

this will drive us crazy quickly :woozy_face:

This is how our QWERTY keyboard looks like, the differences are noticeable.:

Saludos!

1 Like