|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
  |
|
JSON datatypes - parser details |
View previous topic :: View next topic |
Author |
Message
|
MrSmith |
Posted: Thu Mar 11, 2021 1:08 pm Post subject: JSON datatypes - parser details |
|
|
 Master
Joined: 20 Mar 2008 Posts: 215
|
Hi
ACE 11.0.0.9
Incoming request - JSON parser, validate content and value set.
If you were to set say a json defined element as decimal and send in 99.t45 it quite rightly fails the parsing
If you send in "999.88" then the parser allows that to go as it would appear that it does not check the data type (character obviously) against the json.
This you can CAST etc but I am looking to know if there is any way of being able to access what the parser has set that too, aka if i debug this in the toolkit and look in the message tree it will say my value is CHARACTER: 999.88, what i want to ba able to do is throw and error on this cos i know it should have been a Number as defined in the json
FIELDTYPE is not relevant as this lonly tells you if it is a type of Field or element or whatever, not what its datatype is
I could go down the path of DFDL but dont at this point really want to apply a "schema" of sorts to this
Any thoughts welcome
TIA _________________ -------- *
“Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.” |
|
Back to top |
|
 |
timber |
Posted: Fri Mar 12, 2021 6:57 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Not sure if this is what you meant, but you definitely do not want to parse JSON using DFDL!
What you really need is JSON validation, but ACE does not have that yet. Do you really need this check? Are clients of this API really going to supply a string instead of a decimal in this named field? If they do, will it actually be dangerous to auto-cast that string to a decimal? |
|
Back to top |
|
 |
MrSmith |
Posted: Thu Mar 18, 2021 4:56 am Post subject: |
|
|
 Master
Joined: 20 Mar 2008 Posts: 215
|
timber
First thanks for the reply.
No ideally i would like the parser to sort this for me or perhaps even a "new" ESQL function that will pass back the actual datatype as would be equiv to typeof in other languages.
You say ACE doesn't have that YET, is there a [plan for it then? and if so any guess on when that is likely to be?
In truth I have managed to get around the situation by a mixture of declaring a handler and casting, but for this instance the testers fail the code because it starts with a double quotes denoting string when the yaml defines say decimal and therefore it fails even though the output is rectified to the proper datatype.
any insider info on the above would be greatly appreciated. _________________ -------- *
“Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.” |
|
Back to top |
|
 |
timber |
Posted: Thu Mar 18, 2021 9:28 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Quote: |
In truth I have managed to get around the situation by a mixture of declaring a handler and casting, but for this instance the testers fail the code because it starts with a double quotes denoting string when the yaml defines say decimal and therefore it fails even though the output is rectified to the proper datatype. |
You cannot do better than that using native ACE facilities. If you really require JSON validation then I recommend a JavaCompute node with a 3rd party validating JSON parser.
Quote: |
any insider info on the above would be greatly appreciated |
Sorry, not an insider these days  |
|
Back to top |
|
 |
MrSmith |
Posted: Fri Mar 19, 2021 2:10 am Post subject: |
|
|
 Master
Joined: 20 Mar 2008 Posts: 215
|
nice one timber and yes might be an option - call out to java or JCN
Thanks _________________ -------- *
“Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.” |
|
Back to top |
|
 |
|
|
  |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|