Giter VIP home page Giter VIP logo

Comments (5)

raymondfeng avatar raymondfeng commented on May 10, 2024

What about https://github.com/dominictarr/JSONStream?

from loopback-next.

bajtos avatar bajtos commented on May 10, 2024

@raymondfeng

AFAICT from JSONStream's README, it's solving a different problem.

In LoopBack, we have a single object/array returned by a remote method (a Controller method) that we want to write to the HTTP response stream.

JSONStream allows users to write the JSON array-items/object-properties via a streaming interface. I don't see how this is going to improve our performance in the case where we already have the full response object available?

It would be useful if our ORM/DAO implementation provided methods returning a stream of array items (think of MyModel.find returning a stream instead of an array, or already-implemented KeyValueModel.iterateKeys returning an async iterator). However, that is out of scope of this issue. I opened a new story to track this idea - see #122

from loopback-next.

ritch avatar ritch commented on May 10, 2024

AFAICT from JSONStream's README, it's solving a different problem.

This is totally different. The performance increase is similar to ProtoBuffs minus the binary (footprint) benefits.

I'm guessing this approach uses the fact that the JSONSchema acts as essentially a template that is rendered by the serializer instead of JSON.stringify() which has to walk a potentially infinitely complex tree.

Rendering the template is much simpler than walking the tree since the template basically gives the serializer a map of where to go.

from loopback-next.

raymondfeng avatar raymondfeng commented on May 10, 2024

I'm also concerned about the requirement of a schema. The API input/output tends to be flexible and extensible.

The JSON parse/stringify is not only CPU intensive, but also memory heavy. We see issues at both incoming http req/res and outgoing REST calls to other services. It often involves stream --> string --> object or vice versa. I think JSONStream can partially remove the need of string phase.

from loopback-next.

bajtos avatar bajtos commented on May 10, 2024

I am closing this issue because we are not going to have time to work on this in the next 6-9 months. However, we are happy to accept a pull request contributing this feature.

from loopback-next.

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.