JDP Science Tools

annulla
Visualizzazione dei risultati per 
Cerca invece 
Intendevi dire: 

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"] }
  }
}
Messaggio 1 di 27
6.249Visualizzazioni

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
Messaggio 2 di 27
6.229Visualizzazioni

@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". 

Messaggio 3 di 27
6.223Visualizzazioni

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.

Messaggio 4 di 27
6.219Visualizzazioni

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
Messaggio 5 di 27
6.201Visualizzazioni

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

0 Kudos
Messaggio 6 di 27
5.872Visualizzazioni

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

0 Kudos
Messaggio 7 di 27
5.560Visualizzazioni

I'd like this very much as well

0 Kudos
Messaggio 8 di 27
5.304Visualizzazioni

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

Messaggio 9 di 27
5.018Visualizzazioni

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
Messaggio 10 di 27
4.987Visualizzazioni