summary refs log tree commit diff stats
path: root/lib/std/jsonutils.nim
Commit message (Collapse)AuthorAgeFilesLines
* fixes #21638; `fromJson` should support empty objects (#21641)ringabout2023-04-111-11/+16
| | | | | * fixes #21638; `fromJson` should supports empty objects * complete the logic
* remove legacy code (#21134)ringabout2022-12-261-16/+2
| | | | | * remove legacy code * fixes
* stdlib organization & documentation improvements (#20971)metagn2022-12-061-1/+1
| | | | | | | | | | | | | | | | | * stdlib organization & documentation improvements * fix CI * Update doc/lib.md Co-authored-by: Juan Carlos <juancarlospaco@gmail.com> * fix ci, remove jshttpcore, export in jsfetch instead * fix alphabetical order violations * add cmdline, db_odbc Co-authored-by: Juan Carlos <juancarlospaco@gmail.com>
* Add better error messages to `std/jsonutils` (#20629)Jake Leahy2022-10-241-7/+7
| | | | | * Add better error messages * Add fmt on tuple msg
* Fix tuple size check in `std/jsonutils` (#20637)Jake Leahy2022-10-241-2/+12
| | | | | | | | | | | * Add test for tuple being invalid size * Test tuple size before accessing fields * Fix formatting for import * Fix not being able to build from csources_v1 Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* Pass json options to hooks (#20638)Jake Leahy2022-10-241-14/+16
| | | | | | | | | | | * Added tests * Fix expected string * Allow hooks to take an optional parameter that is the current options * Add options to hooks for other generic types * Fix doc links
* move assertions out of system (#19599)flywind2022-03-231-0/+3
|
* rename nimLegacyJsonutilsHoleyEnum [backport] (#18938)flywind2021-10-011-1/+5
| | | | | * enable nimPreviewJsonutilsHoleyEnum [backport] * docuement nimPreviewJsonutilsHoleyEnum
* Add optional recursive arg to distinctBase (v2) (#18659)Timothee Cour2021-08-091-2/+2
| | | | | | * Add optional recursive arg to distinctBase * Add docs and examples Co-authored-by: ALANVF <alan.invents@gmail.com>
* up to 20x faster jsonutils deserialization (#18183)Timothee Cour2021-06-051-6/+6
| | | | | * up to 20x faster jsonutils deserialization * noinline
* simplify extccomp.nim json logic via jsonutils; fix #18084 (#18100)Timothee Cour2021-06-031-1/+17
| | | | | | * simplify extccomp.nim json logic via jsonutils * fix #18084 * simplify further * workaround for bootstrap that can be removed after updating csources_v1 >= 1.2
* jsonutils.toJson now serializes JsonNode as is by default (#18097)Timothee Cour2021-05-311-4/+16
| | | | | * jsonutils.toJson now serializes JsonNode as is (without deep copy nor treating it as a regular ref object) * JsonNodeMode
* jsonutils: add customization for toJson via `ToJsonOptions`; generalize ↵Timothee Cour2021-05-181-11/+32
| | | | | | | | | | | | | | | | | | | symbolName; add symbolRank (#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>
* fix #18007: std/json now serializes nan,inf,-inf as strings instead of ↵Timothee Cour2021-05-161-0/+3
| | | | | | | | | | | | | | | | | invalid json (#18026) * fix #18007: std/json now serializes nan,inf,-inf as raw strings instead of invalid json * fix roundtrip * fix tests * fix changelog * simplify * add runnableExamples * fix typo [skip ci]
* jsonutils: handle holey enum as regular enum, via ord (#17995)Timothee Cour2021-05-111-0/+3
|
* jsonutils: support set (#17994)Timothee Cour2021-05-111-1/+5
|
* CIs: attempt to use csources_v1 (#16282)Andreas Rumpf2021-04-211-9/+9
| | | | | | | | * CIs: attempt to use csources_v1 * also updated the BSDs * also updated azure pipelines * std modules should not itself use the 'std/' import dir... * compiler has to be careful with std/ for v1 booting
* jsonutils: support cstring (including as Table key); improve docs (#16062)Timothee Cour2021-03-311-5/+17
| | | | | * jsonutils: support cstring (including as Table key); improve docs * changelog * un-disable a test now that #16061 was fixed
* fix #17383: json.%,to and jsonutils.formJson,toJson now works with ↵Timothee Cour2021-03-161-1/+3
| | | | | | | uint|uint64 (#17389) [backport:1.2] * fix #17383: json.%,to and jsonutils.formJson,toJson now works with uint|uint64 * fixup * fix for js
* Change stdlib imports to use std prefix in most examples (#17202)Danil Yarantsev2021-02-281-8/+8
|
* use typeof instead type (#16962)flywind2021-02-081-2/+2
|
* jsonutils.jsonTo: support opt (#16739)Timothee Cour2021-01-171-2/+2
|
* Jsonutils: pass opt for object in object (#16615)inv20042021-01-071-1/+1
| | | | | * jsonutils: fromJson forward opt param fix * jsonutils: object in object test + fix: opt pass
* jsonutils: fromJson forward opt param fix (#16612)inv20042021-01-061-4/+4
|
* Fix broken links in docs (#16336)Elliot Waite2020-12-141-4/+4
| | | | | * Fix broken links in docs * Fix rand HSlice links
* Correct all eggs (#15906)Miran2020-11-101-1/+1
| | | | * "eg" is a misspelled "egg", "e.g." is "exempli gratia" * Also, "ie" is "i.e.".
* Add some enhancements to `jsonutils.nim` (#15133)Ivan Bobev2020-09-091-31/+247
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add some enhancements to `jsonutils.nim` * Use `jsonutils.nim` hookable API to add a possibility to deserialize JSON arrays directly to `HashSet` and `OrderedSet` types and respectively to serialize those types to JSON arrays. * Also add a possibility to deserialize JSON `null` objects to Nim option objects and respectively to serialize Nim option object to JSON object if some or to JSON `null` object if none. * Move serialization/deserialization functionality for `Table` and `OrderedTable` types from `jsonutils.nim` to `tables.nim` via the hookable API. * Add object `jsonutils.Joptions` and parameter from its type to `jsonutils.fromJson` procedure to control whether to allow deserializing JSON objects to Nim objects when the JSON has some extra or missing keys. * Add unit tests for the added functionalities to `tjsonutils.nim`. * improve fromJsonFields * Add changelog entry for the jsonutils enhancements * Add TODO in `jsonutils.nim` * Added an entry to "Future directions" section in `jsonutils.nim` as suggestion for future support of serialization and de-serialization of nested variant objects. * Added currently disabled test case in `tjsonutils.nim` for testing serialization and de-serialization of nested variant objects. * Move JSON hooks to `jsonutils.nim` Move `fromJsonHook` and `toJsonHook` procedures for different types to `jsonutils.nim` module to avoid a dependency of collections modules to the `json.nim` module. The hooks are removed from the following modules: * `tables.nim` * `sets.nim` * `options.nim` * `strtabs.nim` * Add some tests about `StringTableRef` Add tests for `StringTableRef`'s `fromJsonHook` and `toJsonHook` to `tjsonutils.nim`. * Disable a warning in `jsonutils.nim` Mark `fun` template in `jsonutils` module with `{.used.}` pragma in order to disable `[XDeclaredButNotUsed]` hint. The template is actually used by the `initCaseObject` macro in the same module. Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
* fromJson: support object variants (#14694)Timothee Cour2020-06-241-15/+73
|
* make `fromJson/toJson` work with `array[range, typ]`, + 1 bugfix (#14669)Timothee Cour2020-06-151-8/+24
| | | | | * make toJson more robust * properly handle array
* `toJson`, `jsonTo`, json (de)serialization for custom types; remove ↵Timothee Cour2020-06-081-0/+126
dependency on strtabs thanks to a hooking mechanism (#14563) * json custom serialization; application for strtabs * serialize using nesting * make toJson more feature complete * add since * Revert "Improve JSON serialisation of strtabs (#14549)" This reverts commit 7cb4ef26addb3bb5ce2405d8396df6fd41664dae. * better approach via mixin * toJson, jsonTo * fix test * address comments * move to jsonutils * doc * cleanups * also test for js * also test for vm