Comments (3)
First of all no worries, you did not miss anything :) There is a .raw()
method (*) you can call on the document (or any other element) to serialize it into a native JS object - this is intended for inspecting and debugging though:
enolib.parse('> note\ngreeting: hello').raw();
// returns approximately [ { comment: 'note', key: 'greeting', value: 'hello' } ]
Background: Given that the eno language itself has no knowledge of types there would be no way to serialize a value to anything other than string
, and given that eno documents and elements can flexibly represent both associative and sequential data structures, there would also be no canonical serialization structure that would be an optimal data layout for both usecases (.raw()
needs to return a sequential representation because a pure associative representation would lose the order).
So indeed one has to manually serialize the document! The reward for this is implicit validation, all the types one can imagine and a lot less syntax and overhead when writing content, but yes it takes some getting used to. :)
Any further questions, just let me know - thanks for having a look!
(*) I'll make sure to add it to the documentation (which is still fresh), got overlooked sorry :) And I'll also see that I create an FAQ entry on the general topic of serialization on the website, I think this would be very helpful as I realize now.
from enolib.
One more thing: I'm considering some of the feedback and questions I received lately - would you feel that for instance an included CLI tool to infer and auto-generate boilerplate deserialization code would be something helpful for your particular way of working? Or would you rather just write the serialization code from scratch yourself and would prefer, e.g. better documentation, or more examples, or something else instead? Thanks for your feedback in advance :)
from enolib.
Update: I added the missing documentation for raw()
and an FAQ entry on this topic at https://eno-lang.org/enolib/javascript/addendum/faq/ 🎉
from enolib.
Related Issues (7)
- eno file writing HOT 1
- C# Parser HOT 2
- How to use the JS lib in the frontend? HOT 3
- Related Rust parsers HOT 1
- Exception on multiline field HOT 6
- Tests failing HOT 7
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 enolib.