Comments (11)
FWIW, NSJSONSerialization
ran on heroku for me, I also use a library https://github.com/gfx/Swift-PureJsonSerializer which might be nice to use if you'd prefer to stay truly pure Swift
from vapor.
Yeah the current JSON serializer for Linux is a placeholder for something better. I was hoping to hold out for Apple supporting pure Dictionary
and Array
objects in their Foundation serializer (possibly that is now true in the latest versions of the compiler).
I will look into that repo you linked.
from vapor.
I took a look into a couple JSON serializers for supposedly "Swift on Linux" last night, and none of them worked. The current Linux compiler does not view [String: Any]
as an AnyObject
which they all seem to rely on. Or some rely on defining your JSON like this:
let response: JSON = [
....
]
I'm not a fan of this solution because this destroys the concise syntax of something like:
Route.get("...") { _ in
return [
...
]
}
You can use the Foundation JSON serializer if you explicitly make all of your responses NSDictionary
s with NSString
keys, but that is a pain semantically.
I can't see any solution now besides waiting for the compiler to get its weirdnesses figured out.
from vapor.
I see the problem with the requiring an explicit type addition.
I've solved a similar problem w/ Json convertible types on top of pure json serializer. I'll see if I can apply some of that here so the user could see just a standard concise syntax and we'd be able to convert it in the background.
from vapor.
If you could make a PR or link me to some examples of this working that would be helpful. Also, nice article on Medium. 👍
from vapor.
@tannernelson Will do, might not be until tomorrow, but I have some code that should work for this. I just need to break the convertible component out so we're not doing copy pasta between the two libs.
Glad you saw the medium post, I couldn't find your twitter to link you, let me know if you have one and I'll add it!
from vapor.
My twitter is @tanner0101
And that sounds good. Feel free to submit the PR early/incomplete if you want assistance working on it.
from vapor.
@tannernelson If you didn't see, we're up on http://iosdevweekly.com/
Hopefully can get some more traffic this way! I've started some of the Json convertible stuff, I'll have a pr up soon hopefully 👍
from vapor.
Awesome! :) Congrats.
Also, check out issue #28. There is a potential solution for serializing and parsing mentioned there.
from vapor.
Awesome coverage!
Matthew Clarkson
On 20 Feb 2016, at 6:52 AM, Tanner [email protected] wrote:
Awesome! :) Congrats.
Also, check out issue #28. �There is a potential solution for serializing and parsing mentioned there.
—
Reply to this email directly or view it on GitHub.
from vapor.
Added to roadmap.
from vapor.
Related Issues (20)
- commùit
- Double slash in URLs still breaks route matching with variable parts in vapor 4.92.0 HOT 2
- Trying to build on Ubuntu 20 with swift run and getting Building for debugging... error: emit-module command failed due to signal 9 HOT 2
- Unable to shutdown server HOT 1
- Title
- Vapor URLQueryContainer no longer supports valueless query parameters HOT 4
- Swift Vapor-Save records in Mysql JSON data type during mapping with swift get error- Could not convert MySQL data to String: <MYSQL_TYPE_JSON HOT 6
- Large, streamed request body may result in noSignalReceived preconditionFailure crash HOT 6
- Websocket shouldUpgrade() fail causes empty reply from server HOT 4
- Cannot setup a route returning `[Int: String]` HOT 7
- Log actual port when it's picked by the OS
- 'Flag' URL Query params don't decode into structs HOT 3
- HEAD response should allow non-zero Content-Length HOT 3
- Authentication Cache + Storage crash application HOT 2
- Default to `HTTPClient.shared` when possible HOT 1
- URLFormEncoder does not escape all reserved characters HOT 3
- Return 415 error if compressed request is detected, but not supported
- Crash after installing posix ELG as concurrency executor HOT 1
- Stored property '_id' of 'Sendable'-conforming class 'Todo' is mutable HOT 2
- [routes] does not split path parameter by '/'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vapor.