JDP Science Tools

cancel
Showing results for 
Search instead for 
Did you mean: 

JSONtext: JSON Schema?

It's been suggested that I think about adding a basic JSON validation schema capability to JSONtext.  What do people think?  

 

An example:

{
  "type": "object",
  "properties": {
    "number": { "type": "number" },
    "street_name": { "type": "string" },
    "street_type": { "enum": ["Street", "Avenue", "Boulevard"] }
  }
}
Message 1 of 15
(2,290 Views)

Would you interpret the schema during parsing, on demand, or just include it for the developer's benefit?

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 2 of 15
(2,270 Views)

@Thoric wrote:

Would you interpret the schema during parsing, on demand, or just include it for the developer's benefit?


There would be a new "Validate JSON Schema" VI, that would have inputs for both a JSON Schema, and a JSON Value to validate (ie. it is used on demand).  Would return "Valid" T/F, and hopefully reason for it not being valid.

 

A JSON Schema can specify things like "must include certain items", or "'Temperature' must be a number", or "'Position' must be an array of three numbers". 

Message 3 of 15
(2,264 Views)

Could also have a "Generate JSON Schema from LV Datatype" subVI, that would generate the Schema from an input type (including things like cluster names and types, and enum values).  This could be used be a programmer in a different language to validate that their JSON is in the right form to be understood in LabVIEW.

Message 4 of 15
(2,260 Views)

I have to say, these sound clever and potentially useful. Although I don't have a user case today it's not impossible in the future.

 

Thoric (CLA, CLED, CTD and LabVIEW Champion)


0 Kudos
Message 5 of 15
(2,242 Views)

I love JSON Schema and would love this feature to more easily validate configuration files.

0 Kudos
Message 6 of 15
(1,913 Views)

This would be a great feature. Any plans to actually add this in the near future to the toolkit?

0 Kudos
Message 7 of 15
(1,601 Views)

I'd like this very much as well

0 Kudos
Message 8 of 15
(1,345 Views)

Here is a beta version with JSON Schema.  See the example "JSON Schema Validation".

Message 9 of 15
(1,059 Views)

Thanks James for adding this.

 

It would be nice if the "Failure Reason" would also contain the label of the element that failed.

 

Best Regards,

Stefan

0 Kudos
Message 10 of 15
(1,028 Views)