Comments (14)
I looked a bit at the code and I'm thinking of adding a case "anyOf"
that will call the function again for each key.
What do you think?
from fast-json-stringify.
Can you add a reference to the part of the JSON Schema for this?
π for a PR anyway.
from fast-json-stringify.
Can you add a reference to the part of the JSON Schema for this?
I'm sorry, do you mean the JSON Schema spec ?
from fast-json-stringify.
Yes thanks!! a PR would be very welcome!
from fast-json-stringify.
I created #50 (and started it with failing tests) but I'm not sure how to start the implementation. My first guess was to add a case "anyOf" that will call the function again for each key.
What do you think of that?
from fast-json-stringify.
go for it!
from fast-json-stringify.
Worked a bit on that yesterday and I'm a bit stuck. A achieve to catch anyOf
properties and iterate over the children but I can't see how I could tell to 'try' each one until one pass. I though the method $as[...]
would throw errors if the type doesn't match but they don't.
Any leads?
Thanks
from fast-json-stringify.
I donβt know really. Trying multiple paths and throwing errors completely defeat the purpose of this library.
A possibility might be to use Ajv to validate all the various option, but it would be slower.
from fast-json-stringify.
If it's noted clearly that using anyOf
cannot lead to any optimization but is supported, it could worth it, don't you think?
from fast-json-stringify.
Yes definitely.
from fast-json-stringify.
I finally had some time to work on this but I'm hitting an issue: how can I use ajv
to validate the data inside the generated code? I tried to require it but require
is not defined :/
from fast-json-stringify.
It should be done following this pattern: https://github.com/fastify/fast-json-stringify/blob/master/index.js#L90-L92
from fast-json-stringify.
Thank you! First draft of my implementation ready here
from fast-json-stringify.
Closed by #50
from fast-json-stringify.
Related Issues (20)
- oneOf schemas not matching when an object has a custom toJSON() method HOT 1
- standalone mode can't be devDependancy HOT 5
- Support TypedArrays HOT 1
- Support of JSON Schema draft 2020-12 HOT 4
- Breaking the typia performance advantage HOT 4
- Schema serialization of anyOf/oneOf properties are parsed incorrectly HOT 1
- Recursive validation schema compiles but fails at runtime HOT 5
- error while resolving nested objects HOT 2
- `node:crypto` issues in Next.js HOT 7
- Tuple of date-time does not allow Date HOT 3
- Issue with custom keyword not working in fast-json-stringify HOT 11
- Response schema compiler generated validation code does not check for null values on optional object fields HOT 9
- lack of strictSchema in ajv options results in silent typos
- merged schema cache is messed up HOT 2
- emit CJS/ESM syntax in standalone mode based on AJV code options HOT 1
- When `asString` receives `undefined` an exception is thrown HOT 2
- Date coercion isn't supported by TypeScript types HOT 4
- allOf Schema and additionalProperties result in unexpected result HOT 10
- asStringSmall seem slower than JSON.stringify
- Fast json stringify vs JSON stringify HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fast-json-stringify.