jsonschema

JSON schema validation

心已入冬 提交于 2019-12-03 01:58:28
问题 Is there a stable library that can validate JSON against a schema? json-schema.org provides a list of implementations. Notably C and C++ are missing. Is there a reason I can't easily find a C++ JSON schema validator? Doesn't anyone else want a quick way to validate incoming JSON files? 回答1: Is there a stable library that can validate JSON against a schema? I found a couple hits on google: From the Chromium project: http://aaronboodman-com-v1.blogspot.com/2010/11/c-version-of-json-schema.html

Generate Avro Schema from certain Java Object

本小妞迷上赌 提交于 2019-12-03 01:28:50
Apache Avro provides a compact, fast, binary data format, rich data structure for serialization. However, it requires user to define a schema (in JSON) for object which need to be serialized. In some case, this can not be possible (e.g: the class of that Java object has some members whose types are external java classes in external libraries). Hence, I wonder there is a tool can get the information from object's .class file and generate the Avro schema for that object (like Gson use object's .class information to convert certain object to JSON string). MoustafaAAtta Take a look at the Java

Generating JSON schema from C# class

别等时光非礼了梦想. 提交于 2019-12-02 20:20:34
Is there any way to programmatically generate a JSON schema from a C# class? Something which we can do manually using http://www.jsonschema.net/ Another option which supports generating JSON Schema v4 is NJsonSchema : var schema = JsonSchema4.FromType<Person>(); var schemaJson = schema.ToJson(); The library can be installed via NuGet . Update for NJsonSchema v9.4.3+: using NJsonSchema; var schema = await JsonSchema4.FromTypeAsync<Person>(); var schemaJson = schema.ToJson(); For those who land here from google searching for the reverse (generate the C# class from JSON) - I use those fine online

Should a RESTful API have a schema?

佐手、 提交于 2019-12-02 19:12:17
I was told recently that a proper RESTful API should define a schema for the resources representations it accepts and returns. For example XSD for XML and JSON Schema for JSON. However in all the books and articles on REST I went through this has never seem not only prominent, but even mentioned. Could someone provide some authoritative resources, to clarify if we should be providing schema when developing RESTful APIs? You have to define and communicate the request and response interfaces to your RESTful API somehow so that callers know what you expect in the request and what they can expect

How to generate JSON-Schema from Swagger API Declaration

允我心安 提交于 2019-12-02 14:04:06
I have Swagger API Declaration for services using Swagger v 1.2 My original feeling about Swagger was, that it is very close to JSON Schema (Draft 3 and lately Draft 4) and it shall be relatively easy to generate JSON Schema for request and response objects. However, while part of the Swagger reuses JSON Schema structures, it turned out, it uses only subset of features, and it also introduces it's own inheritance in Models (using subTypes and discriminator ) . Question: Is there any existing project or piece of code, which can generate usable JSON Schema from Swagger API Declaration ?

How can i write the json schema if json has multiple data set

拥有回忆 提交于 2019-12-02 12:55:38
I am new to this json schema , i am able to write json schema if it has only one data set like below { "employees": [ { "id": 1, "name": "aaa" } } example json-schema for this is { "type" : "object", "required" : ["employees"], "properties" : { "employees" : { "type" : "Array", "items" : [ "properties" : { "id" : {"type" : "integer"}, "name" : {"type" : "string"}, }, "required" : ["id","name"] ] } } } but i got stuck to write json schema in ruby if we have multiple data sets { "employees": [ { "id": 1, "name": "aaa" }, { "id": 2, "name": "bbb" }, { "id": 3, "name": "cccc" }, { "id": 4, "name":

how to set the type of a schema object based on the value of another property?

与世无争的帅哥 提交于 2019-12-02 11:39:14
问题 I have an object (from a 3rd party, so I can't change it) that have a property named "key", and another property called "value" that is optional, and it's type depends on the value of the "key" property. For instance: If the key is "comment", the type of value {"Text":"commentValue"} . If the key is "offset", the type of value is {"seconds":int} . If the key is "weather", the type of value is {"value": Enum["sun", "clouds", "rain"...]} Moreover, some of the keys do not have the value property

How to specify which oneOf item a JSON object should take?

不问归期 提交于 2019-12-02 09:54:18
问题 Using Python and jsonschema I am trying to validate the assignment of ObjA or ObjB etc. to beta ( test.json ) { "alpha": { "beta": "ObjA" } } In my schema ( testschema.json ) beta is oneOf a number of items and each item is defined as below (with differing values for a , b , and c ) "ObjA": { "type": "object", "properties": { "items": { "a": [90, 95], "b": [4, 8], "c": [0.2, 0.6] } }, "additionalProperties": false } That is to say, beta can take on oneOf values that are ObjA , ObjB , ObjC and

Can JSON integer attributes be referenced?

佐手、 提交于 2019-12-02 07:57:51
I have the following JSON schema that I want to validate and Python unittest. { "properties": { "traffic_parameters" { "capacity": { "oneOf": [ { "max_percentage": { "type": "integer", "minimum" : 1, "maximum" : 150 }, "min_percentage": { "type": "integer", "minimum" : 1, "maximum" : { "$ref": "#/properties/traffic_parameters/capacity/oneOf/max_percentage/minimum" } } }, { "percentage_range": { "type": "array", "minItems": 1, "maxItems": 10, "items": { "type": "integer" } } } ] } } } } Using jsonschema I validate the whole schema file OK. However, on writing unittests I get the following error

how to set the type of a schema object based on the value of another property?

99封情书 提交于 2019-12-02 07:03:15
I have an object (from a 3rd party, so I can't change it) that have a property named "key", and another property called "value" that is optional, and it's type depends on the value of the "key" property. For instance: If the key is "comment", the type of value {"Text":"commentValue"} . If the key is "offset", the type of value is {"seconds":int} . If the key is "weather", the type of value is {"value": Enum["sun", "clouds", "rain"...]} Moreover, some of the keys do not have the value property, so the schema should forbid it from appearing with these keys. one of these keys is "standby" (as you