kherge / php.json Goto Github PK
View Code? Open in Web Editor NEWA library for simplifying JSON linting and validation.
License: Other
A library for simplifying JSON linting and validation.
License: Other
Add the following versions to the test matrix:
<?php
use KHerGe\JSON\JSON;
use TestCase;
class JsonValidatorTest extends TestCase
{
/**
* @throws \KHerGe\JSON\Exception\ValidationException
*/
public function testValidElementJson()
{
$error = '';
$validator = $this->app->make(JSON::class);
$element = json_decode('{"settings":{"required":"true"}}');
$validator->validate(
$validator->decode($this->getSchema()),
$element);
}
private function getSchema()
{
return '
{
"type":"object",
"properties": {
"settings": {
"type": "object",
"oneOf": [
{"$ref": "#/definitions/requiredOnly"}
]
}
},
"required":["settings"],
"definitions": {
"requiredOnly": {
"properties": {
"required": {"type": "boolean"}
},
"required": ["required"]
}
}
}';
}
}
Throws: file_get_contents(): Filename cannot be empty
As title, it seems that this repository name has been changed.
However, the Travis CI build service are not binding again.
@kherge , it should be fixed, and other repositories have similar issue, too.
When I visit the herrera-io/json, it's abandoned.
And it looks like the replaced package is kherge/json
.
@kherge, does the abandoned package have any suggestion about replaced package?
The JSON extension should be listed as a requirement in Composer.
Would be pretty useful.
Is there Symfony bundle for this library?
I would like to validate a JSON using the validate method.
This is the file for my schema:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"additionalProperties": false,
"definitions": {},
"id": "http://example.com/example.json",
"properties": {
"commit": {
"additionalProperties": false,
"properties": {
"author_email": {
"type": "string"
},
"author_name": {
"type": "string"
},
"authored_date": {
"type": "string"
},
"committed_date": {
"type": "string"
},
"committer_email": {
"type": "string"
},
"committer_name": {
"type": "string"
},
"id": {
"type": "string"
},
"message": {
"type": "string"
},
"parent_ids": {
"additionalItems": false,
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"message": {
"type": "string"
},
"name": {
"type": "string"
},
"release": {
"additionalProperties": false,
"properties": {
"description": {
"type": "string"
},
"tag_name": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
}
And this is the JSON im trying to validate:
{
"release": {
"tag_name": "test",
"description": "some random text here"
},
"message": "hallo",
"commit": {
"author_email": "[email protected]",
"id": "182391378ajskdjj2ร001jklakmsd92",
"parent_ids": [
"aksjld9209302aklls002kads"
],
"message": "random string",
"authored_date": "2016-02-25T15:19:57.000+00:00",
"author_name": "Pete",
"committed_date": "2014-02-25T15:19:57.000+00:00",
"committer_name": "Pete",
"committer_email": "[email protected]"
},
"name": "test"
}
For some reason the validate method never throws anything if I change the JSON on purpose ans is always null
This is how im using the method:
$schema = $json->decodeFile('valid_json_schema.json');
$json->validate( $schema, $tagData );
Am I missing something or is there really something broken?
Regards!
If possible, the library should support the currently supported version of json-schema and the 5.0 version.
Hi,
In file Herrera/Json/Json.php there is a bug when You call json_decode without leading \ . This results in PHP Error
PHP Fatal error: Call to undefined function Herrera\Json\json_decode()
Lines 57, 59 should be changed to \json_decode(.....)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.