Git Product home page Git Product logo

php.json's People

Contributors

kherge avatar peter279k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

php.json's Issues

Passing Schema file with reference to definition inside file fails to find definition.

<?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

Travis CI status badge are unknown

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.

validate doesnt work

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!

json_decode and Namespaces.

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(.....)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.