Giter Club home page Giter Club logo

Comments (3)

simonrepp avatar simonrepp commented on June 12, 2024 2

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.

simonrepp avatar simonrepp commented on June 12, 2024 1

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.

simonrepp avatar simonrepp commented on June 12, 2024 1

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)

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.