Code Monkey home page Code Monkey logo

streaming-json-encoder's People

Contributors

jtojnar avatar riimu avatar snapshotpl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

streaming-json-encoder's Issues

Complex JSON output?

Not an issue, but a request for an example.

Before I start testing with it, is it possible for your JSON stream library to create more complex objects? For example, I have a generator which will give arrays to output, but they go in a subsection of the response json:

{
 "@count": 37,
 "@data": [
   {
     "id": 1,
     "name": "bob"
   },
   ...more items
 ]
}

My generator only creates the items which go under @data. Can you give an example of how this could be done? Or is it as easy as just passing in another buffer encoder as a value to the top level encoder?

I'll probably play with this later today. If you have time to answer, that would help a lot.

JsonStream should not always be seekable

If a BufferJsonEncoder encodes a Generator, or a value that points to a Generator, JsonStream is no longer seekable. This breaks passing JsonStream as the response body of some frameworks. Slim v4 in particular attempts to read the first byte of a seekable body to determine if the response is empty, then rewinds.

The exception triggered is Cannot rewind a generator that was already run, caused by calling AbstractJsonEncoder::getIterator() twice on the same generator (JsonBuffer::rewind() calls AbstractJsonEncoder::rewind() which resets the stack).

I am pretty sure it's impossible to make JsonStream detect if it's safe to return isSeekable()==true, but I think it would be useful to have a setSeekable(bool $value) method to mark a stream as unseekable for such cases.

Content-Type is text/html; charset=UTF-8

The content type in the HTTP Header is always "Content-Type: text/html; charset=UTF-8".

For JSON this should be "Content-Type: application/json; charset=UTF-8"

Setting the header manually did not work.

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.