New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Unbox capability #1

Closed
VivienGiraud opened this Issue Nov 3, 2016 · 9 comments

Comments

Projects
None yet
2 participants
@VivienGiraud

VivienGiraud commented Nov 3, 2016

Hi,

It would be pretty neat if you can add Unbox capability.
What do you think about that?

Regards,
Vivien

@ijoshsmith

This comment has been minimized.

Show comment
Hide comment
@ijoshsmith

ijoshsmith Nov 3, 2016

Owner

Hi Vivien. Why would you want this tool to support generating Swift code that uses the Unbox API for working with JSON? That project's motto is "The easy to use Swift JSON decoder". But the point of json2swift is that you don't need to write any code at all to decode JSON: the tool writes it all for you.

Thanks,
Josh

Owner

ijoshsmith commented Nov 3, 2016

Hi Vivien. Why would you want this tool to support generating Swift code that uses the Unbox API for working with JSON? That project's motto is "The easy to use Swift JSON decoder". But the point of json2swift is that you don't need to write any code at all to decode JSON: the tool writes it all for you.

Thanks,
Josh

@ijoshsmith

This comment has been minimized.

Show comment
Hide comment
@ijoshsmith

ijoshsmith Nov 3, 2016

Owner

By the way, @VivienGiraud I am not dismissing your request for Unbox support. I really want to know if there is a legitimate reason for doing this, which I have not thought of.

Josh

Owner

ijoshsmith commented Nov 3, 2016

By the way, @VivienGiraud I am not dismissing your request for Unbox support. I really want to know if there is a legitimate reason for doing this, which I have not thought of.

Josh

@VivienGiraud

This comment has been minimized.

Show comment
Hide comment
@VivienGiraud

VivienGiraud Nov 3, 2016

Hi @ijoshsmith,
I mean, you take json file like:

{  
  "name": "John",  
  "age": 27  
}

And get:

struct User {
  let name: String
  let age: Int
}

extension User: Unboxable {
    init(unboxer: Unboxer) throws {
        self.name = try unboxer.unbox(key: "name")
        self.age = try unboxer.unbox(key: "age")
    }
}

I might be wrong with the usage of your tool, in this case I'm sorry :/

Vivien

VivienGiraud commented Nov 3, 2016

Hi @ijoshsmith,
I mean, you take json file like:

{  
  "name": "John",  
  "age": 27  
}

And get:

struct User {
  let name: String
  let age: Int
}

extension User: Unboxable {
    init(unboxer: Unboxer) throws {
        self.name = try unboxer.unbox(key: "name")
        self.age = try unboxer.unbox(key: "age")
    }
}

I might be wrong with the usage of your tool, in this case I'm sorry :/

Vivien

@ijoshsmith

This comment has been minimized.

Show comment
Hide comment
@ijoshsmith

ijoshsmith Nov 3, 2016

Owner

@VivienGiraud I understood what you meant, but I do not know why you are asking for this. The purpose of libraries like Unbox is to make it easier/faster to write code that consumes JSON. Such libraries add value for developers who write code to consume JSON. When a developer uses json2swift there is no need to write such code. Therefore, there is no benefit (that I know of) in continuing to use libraries such as Unbox if you have a tool that generates all the JSON-consuming code that you need.

Owner

ijoshsmith commented Nov 3, 2016

@VivienGiraud I understood what you meant, but I do not know why you are asking for this. The purpose of libraries like Unbox is to make it easier/faster to write code that consumes JSON. Such libraries add value for developers who write code to consume JSON. When a developer uses json2swift there is no need to write such code. Therefore, there is no benefit (that I know of) in continuing to use libraries such as Unbox if you have a tool that generates all the JSON-consuming code that you need.

@ijoshsmith ijoshsmith closed this Nov 3, 2016

@VivienGiraud

This comment has been minimized.

Show comment
Hide comment
@VivienGiraud

VivienGiraud Nov 3, 2016

Please correct me if I'm wrong, json2swift take a JSON file as input and will output the swift structure of this JSON file.
I was wondering, it would be great if I can do the same with json2swift, if I'm right with the usage, to create Unbox struct by giving a JSON file that come from Spotify or IMDB API for example.
When I want to connect to an API, it's pain in the ass to write all the Unbox things to consume JSON.

VivienGiraud commented Nov 3, 2016

Please correct me if I'm wrong, json2swift take a JSON file as input and will output the swift structure of this JSON file.
I was wondering, it would be great if I can do the same with json2swift, if I'm right with the usage, to create Unbox struct by giving a JSON file that come from Spotify or IMDB API for example.
When I want to connect to an API, it's pain in the ass to write all the Unbox things to consume JSON.

@ijoshsmith

This comment has been minimized.

Show comment
Hide comment
@ijoshsmith

ijoshsmith Nov 3, 2016

Owner

Technically, yes it's possible to have json2swift generate Swift code that uses the Unbox API. I just don't see why to bother with continuing to use Unbox at all.

If JSON libraries, like Unbox, are a way to make yourself run faster; json2swift is an automobile.

Owner

ijoshsmith commented Nov 3, 2016

Technically, yes it's possible to have json2swift generate Swift code that uses the Unbox API. I just don't see why to bother with continuing to use Unbox at all.

If JSON libraries, like Unbox, are a way to make yourself run faster; json2swift is an automobile.

@VivienGiraud

This comment has been minimized.

Show comment
Hide comment
@VivienGiraud

VivienGiraud Nov 3, 2016

Hmmm, ok.
Unbox is an extra layer to decode JSON, json2swift serialise it without extra layer.
So if my previous sentence is correct, I understand how dumb my request is...

Sorry about the confusion.

VivienGiraud commented Nov 3, 2016

Hmmm, ok.
Unbox is an extra layer to decode JSON, json2swift serialise it without extra layer.
So if my previous sentence is correct, I understand how dumb my request is...

Sorry about the confusion.

@ijoshsmith

This comment has been minimized.

Show comment
Hide comment
@ijoshsmith

ijoshsmith Nov 3, 2016

Owner

No problem, it's not a dumb request at all! Thinking in terms of code generation can take a little getting used to. Thank you for taking an interest in my project and bringing this up.

Owner

ijoshsmith commented Nov 3, 2016

No problem, it's not a dumb request at all! Thinking in terms of code generation can take a little getting used to. Thank you for taking an interest in my project and bringing this up.

@VivienGiraud

This comment has been minimized.

Show comment
Hide comment
@VivienGiraud

VivienGiraud Nov 3, 2016

Anyway, I'm was looking for something like that since some weeks.
Definitely worth a try when I have some part time.
All the best!

VivienGiraud commented Nov 3, 2016

Anyway, I'm was looking for something like that since some weeks.
Definitely worth a try when I have some part time.
All the best!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment