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

Rework JSON DSL #794

Merged
merged 2 commits into from
Apr 13, 2020
Merged

Rework JSON DSL #794

merged 2 commits into from
Apr 13, 2020

Conversation

qwwdfsad
Copy link
Collaborator

@qwwdfsad qwwdfsad commented Apr 8, 2020

Fixes #418
Fixes #627

After investigation, it seems like non-escaped content does not cause any troubles when used by kotlinx.serialization. The only harmful behaviour may be when a user serializes JsonElement by hand expecting it to be fully-compliant (-> escaped). Added a note to clarify it

Addresses #773
@qwwdfsad qwwdfsad marked this pull request as ready for review April 8, 2020 13:10
@altavir
Copy link

altavir commented Apr 8, 2020

I completely agree with decision to deprecate "pretty" DSL, espcially to infix. It is a source of a lot of errors. In my project I've replaced to by put infix, and it works much better. Also it is possible to use following syntax:

infix fun String.put(builderAction: JsonObjectBuilder.() -> Unit) = addJson(this,builderAction)

It allows to write:

json{
  "child" put {
    "subChild" put "fff
  }
}

@sandwwraith
Copy link
Member

sandwwraith commented Apr 10, 2020

Changes are fine. WDYT of adding jsonOf function and making JsonObjectBuilder implement mutable map?

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

Successfully merging this pull request may close these issues.

3 participants