File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ that can be validated and mapped to programming language types.
1717| [ Rust] ( ./rust/ ) | ` json-structure ` | ✅ Available |
1818| [ Perl] ( ./perl/ ) | ` JSON::Structure ` | ✅ Available |
1919| [ C] ( ./c/ ) | ` json-structure ` | ✅ Available |
20+ | [ PHP] ( ./php/ ) | ` json-structure/sdk ` | ✅ Available |
2021
2122## Features
2223
@@ -318,6 +319,39 @@ int main() {
318319}
319320```
320321
322+ ### PHP
323+
324+ ```bash
325+ composer require json- structure/ sdk
326+ ```
327+
328+ ```php
329+ < ? php
330+
331+ use JsonStructure \SchemaValidator ;
332+ use JsonStructure \InstanceValidator ;
333+
334+ // Validate a schema
335+ $schema = [
336+ ' $schema' = > ' https://json-structure.org/meta/core/v0/#' ,
337+ ' $id' = > ' https://example.com/person.struct.json' ,
338+ ' name' = > ' Person' ,
339+ ' type' = > ' object' ,
340+ ' properties' = > [
341+ ' name' = > [' type' = > ' string' ],
342+ ' age' = > [' type' = > ' int32' ]
343+ ]
344+ ];
345+
346+ $schemaValidator = new SchemaValidator ();
347+ $schemaErrors = $schemaValidator- > validate($schema);
348+
349+ // Validate an instance
350+ $instance = [' name' = > ' Alice' , ' age' = > 30 ];
351+ $instanceValidator = new InstanceValidator ($schema);
352+ $instanceErrors = $instanceValidator- > validate($instance);
353+ ```
354+
321355## Documentation
322356
323357- [JSON Structure Specification ](https: // github.com/json-structure/core)
You can’t perform that action at this time.
0 commit comments