Commit Graph

224 Commits

Author SHA1 Message Date
Timothee Cour
5fe5f47033 followup #17389; add see also in std/json (#17400)
Co-authored-by: flywind <xzsflywind@gmail.com>
2021-03-16 19:21:32 -07:00
Timothee Cour
895a40d1ac fix #17383: json.%,to and jsonutils.formJson,toJson now works with uint|uint64 (#17389) [backport:1.2]
* fix #17383: json.%,to and jsonutils.formJson,toJson now works with uint|uint64
* fixup
* fix for js
2021-03-16 21:44:54 +01:00
flywind
cc37fee0ab fix #17275 (#17276) 2021-03-09 12:22:26 +01:00
flywind
cda443ee68 follow up #17165 (#17262) 2021-03-04 22:41:20 -08:00
flywind
81889fb84c reuse jsffi in json module (#17165)
* remove unnecessary when statement

* remove outdated codes

* reuse jsffi

* move js json coverage
2021-03-04 19:37:12 +01:00
Danil Yarantsev
285539c87a Replace double backticks with single backticks - Part 4 out of ~7 (#17216) 2021-03-01 18:00:58 -08:00
Danil Yarantsev
56461c280f Change stdlib imports to use std prefix in most examples (#17202) 2021-02-28 13:17:19 -08:00
flywind
146beb2797 remove unnecessary when statement (#17135) 2021-02-21 11:17:25 +01:00
Jason Beetham
dde096ffde added enum indexed array support to json (#16807)
* added enum indexed array support to json

* Added json test

* Removed when statement for enum indexed arrays
2021-01-26 00:55:49 +01:00
Neelesh Chandola
0d67ad0bf3 Add backwards index overload for [] for JsonNode (#16501)
* Add backwards index overload for `[]` for JsonNode

* Add since

Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com>

* Add docs, example, and changelog

Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com>
2021-01-04 17:46:39 +01:00
flywind
ef2677f5f3 change some code-blocks to runnableExamples and correct some errors in docs (#15900)
* original docs are wrong
* fix pathnorm
* Update lib/pure/pathnorm.nim

Co-authored-by: Juan Carlos <juancarlospaco@gmail.com>
2020-11-12 10:47:56 +01:00
flywind
7d640e0943 fix #15835 (#15838)
* fix #15835

* add tests
2020-11-04 01:24:40 -05:00
flywind
919593395c fix #15815 (#15817) 2020-11-02 10:22:26 +01:00
Andreas Rumpf
87a60c1b28 fixes #15413 (#15768)
* fixes #15413

* better hide it properly

* see if this makes our list of important packages happy
2020-10-29 17:32:56 +01:00
Miran
14d16c2174 json.nim: smaller init size (#15048)
There was a recent `rightSize` change in tables.nim, so the existing
value (4) was creating too large tables.
2020-07-23 15:42:12 +02:00
Timothee Cour
c7a1a7b8bf toJson, jsonTo, json (de)serialization for custom types; remove 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 7cb4ef26ad.

* better approach via mixin
* toJson, jsonTo
* fix test
* address comments
* move to jsonutils
* doc
* cleanups
* also test for js
* also test for vm
2020-06-08 10:35:23 +02:00
Timothee Cour
d573581eb7 remove isMainModule from json,os,sequtils (#14572)
* move json.isMainModule => tjson

* move isMainModule => tos,tsequtils
2020-06-06 11:50:46 +02:00
PMunch
7cb4ef26ad Improve JSON serialisation of strtabs (#14549)
This creates a more compact serialisation of strtabs that is more in
line with the normal tables.
2020-06-05 10:54:38 +02:00
Jacek Sieka
7d6cbf290a Error -> Defect for defects (#13908)
* Error -> Defect for defects

The distinction between Error and Defect is subjective,
context-dependent and somewhat arbitrary, so when looking at an
exception, it's hard to guess what it is - this happens often when
looking at a `raises` list _without_ opening the corresponding
definition and digging through layers of inheritance.

With the help of a little consistency in naming, it's at least possible
to start disentangling the two error types and the standard lib can set
a good example here.
2020-04-28 19:56:01 +02:00
Vindaar
d42c5a575d base parseEnum on a case statement, fixes #14030 (#14046)
* base `parseEnum` on a case statement, fixes #14030

* apply simplifactions / clean up, remove `norm` node, use strVal

* export `normalize` in json.nim

* cmp using nimIdentNormalize, error at CT if ambiguous enum found

`nimIdentNormalize` provided by @cooldome.

We track all names of the branches we have created so far and error if
a duplicate is found.

Dummy change to make github react...

* fix docstring of `nimIdentNormalize`

* make `typ` arg `typedesc`, add lineinfo, call norm. only once
2020-04-22 09:41:56 +01:00
Nicolai Søborg
b41931bf67 json doc: Note about Option and reserved keywords (#13895) 2020-04-07 15:14:25 +02:00
Andreas Rumpf
cb0f7c5d9e Removed simpleGetOrDefault (#13590) 2020-03-05 21:03:39 +01:00
Ico Doornekamp
73553621a1 Improved assertion error messages on usage of JsonNode iterators on wrong kinds (#13389) 2020-02-17 09:00:25 +01:00
Khronos
006fe4cfc4 Fix vertical tab in JSON. (#13399)
'\v' is not injected in JSON anymore
2020-02-17 00:39:19 +01:00
Timothee Cour
e4415422fe Revert "printing float values will have one more digit. (#13276) [backport]" (#13363)
This reverts commit b2c6db97f9.
2020-02-08 09:30:24 +01:00
Arne Döring
b2c6db97f9 printing float values will have one more digit. (#13276) [backport]
* printing float values will have one more digit. Fixes #13196
2020-02-07 17:10:25 +01:00
Timothee Cour
e5ed4c1b7d fix json regression D20191212T144944 (#12902) [backport] 2019-12-15 23:04:06 +01:00
Neelesh Chandola
ff5ef95414 Fixes #12832 (#12842) [backport]
* Fix #12832
* nimVm -> nimvm in json.nim
* Use suggestSym() instead of markUsed(); Also use styleCheckUse() for finding style violations
2019-12-08 23:27:25 +01:00
Andreas Rumpf
3ba3307d61 remove deprecated procs (#12535) 2019-11-05 11:05:46 +01:00
Nindaleth
34dbc5699e fix several typos in documentation and comments (#12553) 2019-10-30 09:08:45 +01:00
Arne Döring
5ed99f8d3f Extent json.to testing to VM, add workrounds for VM bugs. (#12493)
fixes #12479
2019-10-28 10:06:16 +01:00
Arne Döring
21cbfd72ec Refactor json macro (#12391)
* closes #12316
* make tjsonmacro work at js target
* closes #12289
* closes #11988
* also fixed gdb related stuff
2019-10-17 09:55:41 +02:00
narimiran
b17ed2ca9c [backport] run nimpretty on parsers 2019-09-30 13:58:08 +02:00
Federico Ceratto
39290cf88c Fix spellings (#12277) [backport] 2019-09-27 07:02:54 +02:00
Araq
96b3bae99b json: removed deprecatedGet pragma 2019-09-21 06:43:37 +02:00
Andreas Rumpf
e134a722de fixes #12152 (#12165)
* fixes #12152

* makes test green
2019-09-11 20:28:24 +02:00
Vindaar
eff0837ff4 fixes #12015 by also checking kind of typeNode (#12016)
* fixes #12015 by also checking kind of `typeNode`

If a tuple field is aliased it'll appear the same as a ref type in a
call to `getType` if only for the kind of the resulting `NimNode` is
checked (that is a `nnkBracketExpr`)

* fix test case due to #12017 and add more realistic test case

Adds an additional test case, which includes generics and is closer to
the real failure I encountered

* remove previous fix and fix differently after all

The previous fix was incomplete, because it failed for generics.

Note that the `of "tuple"` is not actually needed, the
`nnkBracketExpr` branch in the `else` branch would catch it too, but I
decided to introduce it for clarity. However, the latter is actually
needed, because it seems for aliases of `seq` we end up in it.

* update comment about global `%` proc in json test
2019-08-27 22:23:47 +02:00
Araq
07d465ca42 [refactoring] remove unused imports in the compiler and in some stdlib modules 2019-07-18 00:36:03 +02:00
Araq
c94647aeca styleCheck: make the compiler and large parts of the stdlib compatible with --styleCheck:error 2019-07-10 12:42:41 +02:00
Liam Sc
a157c2baef Added 'keys' iterator to JsonNode (#11597) [feature] 2019-07-03 08:06:22 +02:00
LemonBoy
7d217a71d3 Render deprecated pragmas (#8886)
* Render deprecated pragmas
* fix the expected html
* clean up the documentation regarding deprecations
* fix typo
* fix system.nim
* fix random
2019-06-03 10:15:20 +02:00
Andreas Rumpf
9d8b4d6020 fixes #11057 (#11345) 2019-05-28 15:55:11 +02:00
Araq
383147f5cb make json.to work with the more restricted case objects 2019-05-27 21:29:02 +02:00
Andreas Rumpf
49e686ab4e fixes #1286; object case transitions are now sound 2019-05-27 21:29:02 +02:00
Miran
bab5e30972 fixes #10963, disallow implicit mixing of strings and ints/floats (#11292) 2019-05-21 21:32:37 +02:00
Miran
2608bc369e json: add '\v' support, fixes #10541 (#10987) 2019-04-10 15:54:49 +02:00
Araq
fda1352ccf json.nim: tiny refactoring 2019-04-01 16:24:04 +02:00
Andreas Rumpf
f8e720fda9 fixes json.nim regression 2019-03-29 08:01:59 +01:00
narimiran
863848ad56 simplify json.% for tuples and objects 2019-03-11 16:51:06 +01:00
LemonBoy
71df1b060b Tighten the conversion from tyRange to scalar types (#10495)
* Tighten the conversion from tyRange to scalar types.

Introduce the `isIntConv` rule for unsigned types.
Do not allow mixed-signedness conversions between ranges and scalar types.

* More json adjustments
2019-02-23 11:52:52 +01:00