[MCS-DE-GO] JSON object with non-string parameters
See original GitHub issueCurrently we are facing the issue that we cannot find the right syntax in a JSON object within the https-Action to send numbers and booleans to an external API.
The only working syntax Composer allows in JSON in https-request body object is:
{
"question": "${conversation.string",
"scoreThreshold": "${conversation.number}",
"context": {
"previousUserQuery": "${conversation.string2}",
"boolean": "${conversation.boolean}"
}
}
This creates this JSON body on API call as output:
{
"question": "und mein hund auch?",
"scoreThreshold": "70",
"context": {
"previousUserQuery": "wer ist alles versichert",
"boolean": "true"
}
}
What we want to have however is this: JSON body on API call expected output:
{
"question": "Hello World",
"scoreThreshold": 70,
"context": {
"previousUserQuery": "Who are you?",
"boolean": true
}
}
We tried different ways of adding the parameters inside the JSON object but the syntax validation and auto-correction in Composer does not allow us to create the correct output.
Please advise on options or the proper syntax for this or add this as a bug.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
How to parse a NON JSON STRING to a Object in javascript
In order to parse JSON5 strings, use JSON5 npm package. Its API is the same as in the standard JSON object: you can...
Read more >JSONSetElement
This function returns json with value set at the specified keyOrIndexOrPath . If the json parameter is blank (""), this function adds value...
Read more >object — Understanding JSON Schema 2020-12 ...
Objects are the mapping type in JSON. They map “keys” to “values”. In JSON, the “keys” must always be strings. Each of these...
Read more >JSON Object Methods :: GSQL Language Reference
This page lists the methods of a JSON object variable. ... If the key provided is associated with a non-string value, the function...
Read more >JSON.stringify() - JavaScript - MDN Web Docs
The JSON.stringify() static method converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dmvtech use an expression for your body instead.
You can also use
SetProperties
to build up your object in memory and you should then be able to just say=dialog.body
This worked for me:
If you set the property as “number” you can also use this:
This also works when you put it in a “Set Property” action as expression. When you try using the “Set property” as “object” the JSON parser will not allow you to add properties without the “${}” syntax which then will always create a string, even when you add the “int()” funtion to it.
I believe this is probably a bug but as the expression syntax works there is a work around. This should however be very clearly documented, if the “object” element cannot be fixed.