Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

JSON Serialization #8

Closed
ldiqual opened this issue Dec 2, 2015 · 4 comments
Closed

JSON Serialization #8

ldiqual opened this issue Dec 2, 2015 · 4 comments

Comments

@ldiqual
Copy link

ldiqual commented Dec 2, 2015

Congratulations on open sourcing Mapper!

I'm comparing ObjectMapper to Lyft's Mapper. To me the only (and very important) difference is first-class support for non-optionals via failable initializers (which ObjectMapper kind of supports, but it's never been officially documented).

What Lyft's Mapper is really missing though is JSON serialization. Is that something that is on your timeline? If so, any idea of when it could be available?

@keith
Copy link
Contributor

keith commented Dec 2, 2015

Right now we don't have any plans for JSON serialization.

The biggest issue is we haven't been able to come up with a way to do this without duplicating the mapping created in the initializer, and I'm not sure we will be able to keeping the current interface.

It seems like ObjectMapper (and a few other libraries) handle this by doing some tricky stuff with the operators and subscripts, which works well (our old mapper did this as well). But since we're using an initializer where we are forced to use = we don't really have that flexibility.

If you have any implementation ideas for how this would work we're definitely open to suggestions though!

@lxcid
Copy link

lxcid commented Dec 7, 2015

Isn't JSON serialisation done by NSJSONSerializer?

If you receive a NSDictionary, you can pass it to the mapper.

I think keeping the mapper as it is now is perfect. DOTADIW.

I actually like how this doesn't try to introduce any new operator, rely on dependency injection, use new error handling, make great use of protocol and generic and Swift inference to get things done.

Great work!

@keith
Copy link
Contributor

keith commented Dec 7, 2015

@lxcid thanks for the kind words! Though I believe what @ldiqual was asking for here was a way to go from Model Objects -> NSDictionary so that you could take the produced NSDictionary and pass it to NSJSONSerialization as needed. The Model Objects -> NSDictionary portion is what might make sense for Mapper, but not something we're planning on just yet. Closing this issue for now, but we're still open to great ideas if anyone has them!

@keith keith closed this as completed Dec 7, 2015
@lxcid
Copy link

lxcid commented Dec 7, 2015

I see! Sorry for the misunderstanding!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants