BlackEdder / painlessjson

D library for converting any custom types to and from JSON the painless way.
Boost Software License 1.0
23 stars 3 forks source link

Automatic camelCase conversion #38

Closed Zalastax closed 9 years ago

Zalastax commented 9 years ago

Resolves issue #33. I have added an option object that can be used to turn this feature on or off. It might be better to move all the functions to an object, but have free functions that make the call using the default-object.

BlackEdder commented 9 years ago

This looks good. I am now just wondering if it would be wise to add loads of switches to the conversion. Maybe it would be easier to add simple helper functions to turn JSONValue representation of a class/struct from/to camelCase. That way the user can always convert the JSON after/before calling toJSON/fromJSON? Might keep it more maintainable than adding special cases/switches.

Zalastax commented 9 years ago

I don't like the idea of having to transform the data before passing it in. That's a step that will be forgotten somewhere. My reasoning for a configuration object is that you might want a certain default for your whole application. If I want camelCase to underscore everywhere I should only have to say that once. If I have one place where I don't want it I should be able to say that as well (using annotations, or modifying the option object for that place).
So I would prefer if we make changes to support:

The current solution only solves the override anywhere problem elegantly, but it could be modified to fit the other problems as well.

Zalastax commented 9 years ago

Any more input to this? What should be done to merge this pull request? How should configurability be approached?

BlackEdder commented 9 years ago

Sorry about the delay. Just started new job, so been bit distracted.