Code Monkey home page Code Monkey logo

Comments (5)

pleonasm avatar pleonasm commented on July 28, 2024

Just to be clear, I would like to try to do this myself (since I have the need). I just want to make sure this approach is acceptable before I go off implementing things.

from json-schema.

mchiocca avatar mchiocca commented on July 28, 2024

Hello. The existing CHECK_MODE_* constants aren't needed. I don't think that adding a new constant is a good idea. The code that deals with these constants should be removed since none of it is being used. Adding new code for a new constant for something like this is probably not a good approach. I wouldn't advocate this. I don't understand your use case so I don't understand why you can't provide the data in its currently expected format. I would suspect that you can find another way to solve your problem that doesn't require your proposed change.

from json-schema.

pleonasm avatar pleonasm commented on July 28, 2024

The use case is that we have a system that wraps json_decode() and forces the true flag as the second argument for consistency. It makes sense this library is supposed to accept json_decode() output, it would make sense to support ANY non-error output from json_decode() rather than json_decode() with the second argument always false.

The code required to deal with this is absolutely something that could live outside of the library, but I figured I'd submit a proposal to put it in the library in case it was useful to anyone else.

If it is not wanted, no big deal.

from json-schema.

mchiocca avatar mchiocca commented on July 28, 2024

Hello. I don't think that introducing a new CHECK_MODE constant when the existing CHECK_MODE related code is not needed and should be removed is the right way to go. The original CHECK_MODE constants were intended for doing PHP-specific type casting, which is something that no json schema validator should do. So, adding a new constant for type casting between array and object isn't something that should be introduced into this library. If you need this functionality it is probably better to keep it outside of this library and add it as part of your own code. So, having your code do whatever conversion is necessary first, then calling this library with the data in the expected format sounds best.

from json-schema.

neural-wetware avatar neural-wetware commented on July 28, 2024

I have application code which decodes JSON in the array style, but have to decode it again to validate against the schema. I'm in a situation where I have to either decode twice or rewrite the app code to use object style.

Is this a compelling enough case for adding this feature? Consider that the JSON structures can potentially be quite large and rewriting application code can be costly.

from json-schema.

Related Issues (20)

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.