Skip to content

Why strings for all datatypes? #386

@SebastianSchildt

Description

@SebastianSchildt

That probably has been discussed in the past, but as the question came up in COVESA/iot-event-analytics#109 and I could not find a rationale in the spec, I will just repost the main points here.

VISSv2 says "Regardless of its data type, a single data item is always represented as a string in message payloads."

can you give some reason, why string is defined in the standard?

and

I agree, that JSON just supports numbers [+string, boolean, array, object] and thus additional checking is mandatory. But clamping or testing out upper lower bounds etc. for numbers can be done using these plain numbers. Transforming strings to numbers and vice versa is actually an additional step. I don't find it cleaner to use strings. I always prefer e.g. comparing boolean to boolean, numbers with numbers... since I know many cases in where people are discussing whether "1", "true", "True", "TRUE", "yes" should be translated to boolean true. That's a pitfall which comes by using stringified values. The same applies to numbers (using "," or "." as a thousand or decimal separator because of English or German is a nightmare to parse)
And if they want to use JSON as their representation of choice, they have to deal with the "limitations" of this format and not making everything on top super complicated to compensate for that. In the end, the whole thing gets complicated without no reason. In addition, strings tend to be misused for "weirdo-datatypes": First byte means this, second bytes this and then, separated by an ampersand there's the value. And don't even try to do another encoding than UTF-8, otherwise you break it.
I know, it's a bit provoking, but I hope you get my point.

Can somebody shed some light why the design decision was to use strings for everything?

Metadata

Metadata

Assignees

No one assigned

    Labels

    VISS v2Generation Two of the spec

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions