hal-forms icon indicating copy to clipboard operation
hal-forms copied to clipboard

Support number, boolean

Open evert opened this issue 4 years ago • 1 comments

Might as well open a ticket for this, as it's something that was discussed in various other threads.

I think it would be great if we can explicitly encode numbers and booleans as numbers and booleans when encoding to application/json, including having the ability to encode 'an array of numbers or booleans' for the "multiple" cases.

evert avatar Jun 16 '21 01:06 evert

as far as i can tell, this will be a breaking change, right?

i've resisted "strong-typing" the message to reduce rejected responses (e.g. the receiver was expecting a boolean and got a number instead). the safest solution is to marshall data as strings and let the receiver do whatever type-casting is required.

i've worked w/ cases where the type information is sent along with the string ({value:"13",type:"currency"}). that's a more complicated solution but it has the advantage of backward compatibility and reduces (doesn't eliminate) type-casting bugs.

thoughts?

mamund avatar Jun 16 '21 23:06 mamund