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,594 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,574 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,568 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,564 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,546 Views)

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

0 Kudos
Message 6 of 15
(2,217 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,905 Views)

I'd like this very much as well

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

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

Message 9 of 15
(1,363 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,332 Views)