0

I need to define one nested JSON object which stores in use case 1 a key value with an integer (amount of something) and in use case 2 a key value with a string (UUID).

The goal is to analyse the data in later procedures.

I know decided to put the number into quotes and get away with implicit conversion. Which has been described here: Can JSON numbers be quoted?

Example-1:

"kpiValue": {
   "type": "Driver",
   "value": 16 // => amount of something
}

Example-2

"kpiValue": {
   "type": "Driver",
   "value": "ident" // => UUID is handled as string
},

Any thoughts on this?

1 Answers1

0

A quoted number is a string.

You can safely do this.

NB: Don't forget to determine and type your variable property afterward.

Ploppy
  • 14,810
  • 6
  • 41
  • 58
  • The snap above is a nested object of two different objects and the determination is made in the upper level of the objects. I thought their might be a more convenient :) – thadubsdavid May 01 '20 at 13:31
  • I'm not sure to understand, are you searching for a workaround or do you want to know if it is ok to do it that way ? – Ploppy May 01 '20 at 13:34
  • Thanks! Considering that I need to analyse this JSON in later procedures.It would be more convenient to store the value as number instead of a string. – thadubsdavid May 01 '20 at 13:41
  • Don't forget to accept the answer if it fits your needs – Ploppy May 01 '20 at 13:45