Skip to content

Conversation

@timotheecour
Copy link
Member

@timotheecour timotheecour commented May 16, 2021

  • jsonutils: add customization for toJson via ToJsonOptions, right now it only allows customizing how to serialize enum's; this could be extend in future to allow other reasonable customizations, eg for serializing char as string instead of int

  • generalize symbolName to allow HoleyEnum; it's used by jsonutils to allow rendering enums via symbol name, arguable a better choice than using the $ (which suffers from sandwich problem, need for synchronization between serializer and deserializer, duplicate name issue and less stable). The default for serializing enums in jsonutils stays the same for reasons previously discussed.

  • add symbolRank which is useful in itself and also used by symbolName

future work

@timotheecour timotheecour marked this pull request as ready for review May 16, 2021 18:15
@timotheecour timotheecour added the Ready For Review (please take another look): ready for next review round label May 16, 2021
@timotheecour timotheecour requested a review from ringabout May 16, 2021 21:07
@Araq Araq removed the Ready For Review (please take another look): ready for next review round label May 18, 2021
@Araq Araq merged commit 7f077a7 into nim-lang:devel May 18, 2021
@timotheecour timotheecour deleted the pr_jsonutils_enum_option branch May 18, 2021 16:37
PMunch pushed a commit to PMunch/Nim that referenced this pull request Mar 28, 2022
…ze symbolName; add symbolRank (nim-lang#18029)

* jsonutils: add customization for toJson via `ToJsonOptions`

* add enumutils.symbolRank

* lookup table implementation for HoleyEnum

* cleanup

* changelog

* fixup

* Update lib/std/jsonutils.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
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.

2 participants