Giter Site home page Giter Site logo

Support strict JSON loading. about nimyaml HOT 5 CLOSED

flyx avatar flyx commented on July 17, 2024
Support strict JSON loading.

from nimyaml.

Comments (5)

flyx avatar flyx commented on July 17, 2024

What would be the benefit of having a dedicated JSON loader? The existing loader is able to load any JSON. I can think of some benefits, but none of them really justify the complexity it adds:

  • Identifying invalid JSON that would be valid YAML (but I am unsure in which scenario NimYAML is the right tool for this)
  • Faster loading (parsing JSON is significantly faster than parsing YAML, though lesser than a magnitude). I once or twice heard about people parsing multiple MBs of data, but that seems to be a rather exotic use-case. For small amounts of data, the performance increase should not be that relevant.
  • Motivating people to use NimYaml instead of marshal to (de)serialize JSON. That would be a marketing reason, which, in my eyes, is not really a good reason.

from nimyaml.

flyx avatar flyx commented on July 17, 2024

For the record, I thought about de-coupling NimYAML's serialization API from the YAML backend so it can be used with different backends (XML, INI, you name it). But unfortunately, this would mean to change the intermediate representation (currently the YamlStream) to accommodate the very different structure of XML, for example. I have not yet succeeded in crafting such a representation that fits all needs, so I currently go with YAML-only.

from nimyaml.

Varriount avatar Varriount commented on July 17, 2024

My use-case is primarily #1. There are some services out there which consume files written in JSON in order to perform actions, and I sometimes have to write scripts which augment existing files created for these services.

from nimyaml.

flyx avatar flyx commented on July 17, 2024

For augmenting an existing JSON file, doesn't it suffice to load it as YAML and dump it with psJson? Your use-case doesn't sound like you would need to ensure that the original file is valid JSON. The augmented file will be.

from nimyaml.

flyx avatar flyx commented on July 17, 2024

Closing this since it is out-of-scope for NimYAML.

from nimyaml.

Related Issues (20)

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.