Giter Site home page Giter Site logo

JSON encoded requests about vapor HOT 9 CLOSED

vapor avatar vapor commented on April 27, 2024
JSON encoded requests

from vapor.

Comments (9)

czechboy0 avatar czechboy0 commented on April 27, 2024

I'd like to humbly point out that I wrote a pure Swift JSON parser for exactly the purpose of using it in my server apps. Parsing seems to work well and is pretty well tested. Serialization into data is finished on a branch, but I'm resolving some final issues.

TL;DR feel free to use it as a dependency to add request parsing from JSON to Vapor (that's already working and tested). Serialization into data will be arriving next week in a new version.

https://github.com/czechboy0/Jay

from vapor.

czechboy0 avatar czechboy0 commented on April 27, 2024

I also noticed that in your manual JSON serializer you're not correctly handling escaping. All that is handled and tested in Jay.

from vapor.

tanner0101 avatar tanner0101 commented on April 27, 2024

So your JSON parser will be able to take a native Swift Dictionary or Array (Any) and convert it into a String?

Example:

let data = [
  "test": [
    "number": 1,
    "string": "abc",
    "double": 3.14,
    "nest": [
      1, 2, 3
    ]
  ]
  ...etc
]

let jsonString: String = YourJsonThing.serialize(data)

If your library does this properly on Linux, then I would love to use it ASAP. The JSONSerializer class I wrote was last ditch effort to get some sort of JSON support working on Linux.

from vapor.

czechboy0 avatar czechboy0 commented on April 27, 2024

Yes exactly. Parsing JSON from data is already released, this JSON object to data serialization I worked and figured out today, it's on a branch. Take a look at the link above, I comment heavily so it should be understandable.

Makes me think - if you have any specific examples of payloads you want to make sure get encoded properly, PR a new test in Jay so that I can add it to the core tests and we can make sure it all keeps working just as expected going forward.

I'm AFK over the weekend, so it might be a good time to add parsing of JSON requests to Vapor, and once I finish the serialization early next week, I'll let you know that there's a tested version ready.

How does that sound?

from vapor.

tanner0101 avatar tanner0101 commented on April 27, 2024

Busy this weekend as well, so I don't know if I will get around to JSON parsing. But as soon as serializing is available let me know. That's a big hold up for Vapor right now.

from vapor.

czechboy0 avatar czechboy0 commented on April 27, 2024

Sounds good. The parsing API will not change, but if you want to wait for the full package, I'll let you know once I'm confident it works well.

Also - I'll use the above example as a parsing test so that I can make sure you're getting what you need.

from vapor.

tanner0101 avatar tanner0101 commented on April 27, 2024

Sounds great. Let me know if you need any assistance/feel free to join the Slack mentioned on Vapor's readme.

from vapor.

loganwright avatar loganwright commented on April 27, 2024

There are also potential suggestions here: #22

Those use PureJsonSerializer which I'm partial to, but don't feel too strongly about

from vapor.

tanner0101 avatar tanner0101 commented on April 27, 2024

Added to roadmap.

from vapor.

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.