Skip to content
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

Is it possible to deserialise object from different camelCase naming strategies? #1423

Closed
ChameleonTartu opened this issue Apr 19, 2021 · 1 comment
Labels

Comments

@ChameleonTartu
Copy link

What is your use case, and why do you need this feature?

I am testing, passing objects from the SunHttp backend from Http4K all the way through Spring Controller.
For example, my object:

@Serializable
data class Order(val OrderName: String)

It appears in the test as {"orderName": "example"}.

After it appears in the test as Entity, I want to stringify it and deserialize it back to the Order object.

Json { ignorUknownKeys = true }.deserializeFromString(EntityUtils.toString(response.entity))

I would expect it to work, or pass there a parameter that will make it work, as it is the same definition of CamelCase

Describe the solution you'd like

I would expect:

  1. Have documentation on how to do it, in case it is possible to do it now.
  2. If it is not, to have a flag saying this is polymorphic to deserialize object:
Json { ignorUknownKeys = true; polymorphicToCamelCase = true }.deserializeFromString(EntityUtils.toString(response.entity))
@sandwwraith
Copy link
Member

Sorry, I don't get the idea. For changing property name, we have serial name annotation. For global policies, there's separate ticket: #33

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

No branches or pull requests

2 participants