fluidsonic / fluid-json Goto Github PK
View Code? Open in Web Editor NEWA JSON library written in pure Kotlin
License: Apache License 2.0
A JSON library written in pure Kotlin
License: Apache License 2.0
readKey()
methodIOException
, InterruptedException
(all Exception
s?) in JSONException
?Input/OutputStream
directly.Appendable
.Readable
.Byte
and Short
.Char
.JSONReader
.readString
and writeString
which operate on CharArray
and alike.TextInput
.If it makes sense. An for what throwables?
java.time.*
Resolution of Int
-> AnyJSONCodec
can't work for decoding.
sealed class Shape
class Circle(val radius: Double) : Shape
class Rectangle(val width: Double) : Shape
There are 2 types of polymorphism:
[ { "type": "CIRCLE", "radius": 10.0 }, { "type": "RECTANGLE", "width": 20.0 } ]
1.2 Discriminator external
[ { "type": "CIRCLE", "data": { "radius": 10.0 } }, { "type": "RECTANGLE", "data": { "width": 20.0 } } ]
anyOf
from Swagger[ { "radius": 10.0 }, { "width": 20.0 } ]
Because only Circle
class has radius
field, first object from list will be deserialized in Circle
class.
Also should be possible to do nested deserialization(multi level).
Please add support for all this cases.
Usually on deserialization we want to collect all validation errors and return them in response to the client.
In order to catch all error the validation should be done before object creation.
If it will be done after object creation, in init
block, than validation will be separated in 2 phases, first one will be validation regarding non-nullable field, because we cannot create objects if they have non-nullable properties.
The second one will be to do structural validation: min/max values, length, regexp pattern, etc.
Example
class Data(val name: String, val age: Int, val email: String)
when we send a json {"email": "[email protected]", "name": "A"}
we should return a response where to indicate that age
can not be null and name
size must be greater than 2, at once to send all the errors.
Also, structural validation will be great to do based on annotations and not in init
block, something like JSR 303.
This will be useful for documentation generation, it is far easier to generate based on annotations.
How I see the flow:
@JSON
class ClientCommand<out Result : Any>(
val resultClass: KClass<out Result>
)
@JSON
class ClientCommandRequest<out Result : Any>(
val command: ClientCommand<Result>
)
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.