Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON schema validation with PHP [closed]

Is there any PHP library that validates a JSON object against a JSON Schema?

like image 787
Omer Avatar asked May 03 '10 11:05

Omer


People also ask

How validate JSON in PHP?

To determine if the JSON output is genuine, PHP includes a method called json_decode(), which was introduced in PHP 5.3. It is a PHP built-in function that is used to decode a JSON string. It creates a PHP variable from a JSON encoded text.

Does JSON have schema validation?

Overview. JSON Schema is a declarative language for validating the format and structure of a JSON Object. It allows us to specify the number of special primitives to describe exactly what a valid JSON Object will look like.

How does JSON Schema validation work?

The simplest way to check if JSON is valid is to load the JSON into a JObject or JArray and then use the IsValid(JToken, JsonSchema) method with the JSON Schema. To get validation error messages, use the IsValid(JToken, JsonSchema, IList<String> ) or Validate(JToken, JsonSchema, ValidationEventHandler) overloads.

What is JSON Schema additionalProperties?

The additionalProperties keyword is used to control the handling of extra stuff, that is, properties whose names are not listed in the properties keyword or match any of the regular expressions in the patternProperties keyword. By default any additional properties are allowed.


1 Answers

I'm using Justin Rainbow's JSON Schema for PHP https://github.com/justinrainbow/json-schema and I'm quite happy about it.

It's a fork of http://jsonschemaphpv.sourceforge.net/

You can easily install it via Composer.

like image 163
paq85 Avatar answered Oct 16 '22 03:10

paq85