Comments (6)
If we're going to have a fromJson CE (not a bad idea) would it make sense to introduce a toJson CE as well? The json CE would probably remain as a more "general" CE perhaps...
from chiron.
Yeah. I've just been re-looking at the Encoder<'a>
type and thinking that it should also accept in the Json context instead of just the function it is now, so as to support "mixin" encoders. If so, then that leads to a toJson {}
CE to support that. We could still have the json {}
CE supported. Though I'm of two minds on retiring it, I'll default to keeping it supported.
from chiron.
The json {}
CE does support more than just mapping to/from. With the Json.Optic.*
support, etc. it supports querying and modification of JSON structures. There is an argument as to whether that's needed outside of a mapping context, but it does so at the moment...
from chiron.
Right. I can see that. Maybe I just haven't had a use case for doing reading during a ToJson
or writing during a FromJson
. The Json.Optic.*
support is definitely still going to be useful. This may be something that I need to throw against the wall to really see what it looks like.
from chiron.
Ok, I can see a reason for the json {}
CE. It exists as a composition of the "state" and "either" monads. What we really need is to "run" the CE. The CE needs to be extended so that it can bind to Encoder
s and Decoder
s. That would allow the more direct serialization/deserialization method to live along side the more general-purpose json {}
method.
from chiron.
Yeah that sounds about right. Your point about reading in a ToJson or writing in a FromJson is completely valid - optics are just general like that. It'll be interesting to see how it works out - I can see ending up with two special case CEs and a general "work with JSON" CE - that might not be a bad thing (I don't tend to use the CEs anyway, but I know they are used).
Saying that does raise one issue in my head. At the moment there's only one type signature for all operations. Breaking that down in to multiple may make the maintenance of operators more complex - you would potentially introduce a requirement to have separate operators for each type. One way round that might be statically resolved operators, but it remains to be seen...
from chiron.
Related Issues (20)
- DateTime should allow other formats
- Darren HOT 1
- Cani
- GetHashCode infinite loop
- How to serialize a list to a Json object HOT 4
- How about deserializeWith? HOT 1
- Convert to use FSharp.Core's new `Result` type
- Json.tryParse "null3" should raise Exception
- Releases are not tagged HOT 2
- No way to build on *nix/MacOS HOT 8
- Warnings when building about portable frameworks
- Null reference exception in Escaping.escape HOT 10
- Add .travis.yml for automated Linux testing HOT 1
- How-to-get-started tutorial HOT 2
- "serializeArrayWith" is missing.
- Object serialization: do not use a `Map<string, Json>`
- Missing tags for current beta release HOT 2
- v7 bind failure?
- v7 reference edge cases
- Add ObsoleteAttribute for old API to ease transition from v6.* HOT 1
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 chiron.