53 Commits

Author SHA1 Message Date
xackus
7a28c644aa new ArrayList API: fix everything else 2020-04-02 16:12:08 +02:00
daurnimator
a32d88f12c
std: add support to std.json.stringify for null literals 2020-04-01 00:12:59 +11:00
daurnimator
62fbb6b874
std: allow picking between serialising []u8 as string or array 2020-04-01 00:12:59 +11:00
daurnimator
edf487b126
std: add options to std.json.stringfy to control escaping 2020-04-01 00:12:59 +11:00
daurnimator
5a053247e2
std: use stringify from Value.dump; remove other dump helpers 2020-04-01 00:12:59 +11:00
daurnimator
e88543a504
std: add jsonStringify trait to json Value objects 2020-04-01 00:07:31 +11:00
daurnimator
48e7c6cca6
std: add whitespace control to json.stringify 2020-03-31 23:57:00 +11:00
daurnimator
3a0875d9e8
std: have json tests take options parameter 2020-03-31 23:19:24 +11:00
Andrew Kelley
9e7ae06249
std lib API deprecations for the upcoming 0.6.0 release
See #3811
2020-03-30 14:23:22 -04:00
Andrew Kelley
c70471fae6
enable now-passing test cases
These can now be enabled thanks to bug fixes that landed in
LLVM 10.
2020-03-29 10:34:12 -04:00
Benjamin Feng
9dbfee49d7 Carry-over stream error to JSON.stringify 2020-03-25 18:54:04 -04:00
Andrew Kelley
7fa88cc0a6
std lib fixups for new semantics
std lib tests are passing now
2020-03-19 09:53:55 -04:00
Benjamin Feng
4aae55b4cc Replace fmt with new fmtstream 2020-03-12 10:41:09 -05:00
Benjamin Feng
2429fdd73b Convert JSON to fmtstream 2020-03-12 10:41:09 -05:00
Andrew Kelley
18f1fef142
update standard library to new I/O streams API 2020-03-10 18:44:30 -04:00
Andrew Kelley
b6fbd524f1
(breaking) improve and simplify fixed buffer streams API 2020-03-10 16:31:04 -04:00
daurnimator
e270db956c
std: tagged unions are broken on arm64 2020-02-19 23:17:04 +11:00
daurnimator
d989396a34
std: add json.parse to automatically decode json into a struct 2020-02-19 23:16:35 +11:00
daurnimator
5a20604820
std: add json.stringify to encode arbitrary values to JSON 2020-02-19 23:01:12 +11:00
LemonBoy
59a243ce24 std: Remove now-superflous hack 2020-02-16 19:53:53 +01:00
daurnimator
6ea6d5a4bd
std: use testing.allocator in tests 2020-02-14 19:15:09 +11:00
Benjamin Feng
a81ae1223d Convert a lot of json tests to use testing.allocator 2020-02-12 17:17:56 -06:00
Andrew Kelley
9f064bcf74
Merge pull request #4091 from xackus/json_copy_strings
json: implement copy_strings=false
2020-01-07 16:42:14 -05:00
xackus
814b54d798 json tests: don't use debug allocator 2020-01-07 19:03:11 +01:00
hryx
2933a8241a json: disallow overlong and out-of-range UTF-8
Fixes #2379

= Overlong (non-shortest) sequences

UTF-8's unique encoding scheme allows for some Unicode codepoints
to be represented in multiple ways. For any of these characters,
the spec forbids all but the shortest form. These disallowed longer
sequences are called "overlong". As an interesting side effect of
this rule, the bytes C0 and C1 never appear in valid UTF-8.

= Codepoint range

UTF-8 disallows representation of codepoints beyond U+10FFFF,
which is the highest character which can be encoded in UTF-16.
Because a 4-byte sequence is capable of resulting in such characters,
they must be explicitly rejected. This rule also has an interesting
side effect, which is that bytes F5 to FF never appear.

= References

Detecting an overlong version of a codepoint could get gnarly, but
luckily The Unicode Consortium did the hard work by creating this
handy table of valid byte sequences:

https://unicode.org/versions/corrigendum1.html

I thought this mapped nicely to the parser's state machine, so I
rearranged the relevant states to make use of it.
2020-01-07 12:07:44 -05:00
xackus
6bebf741f9 json: implement copy_strings=false 2020-01-06 19:59:54 +01:00
daurnimator
42727c73f9
std: fix typo in comment 2019-12-31 03:06:33 +11:00
daurnimator
ef3a01a367
std: json.unescapeString doesn't need to take an allocator 2019-12-31 02:26:09 +11:00
daurnimator
04a2a4a7cb
std: track decoded string length in std.json tokenizer 2019-12-31 02:26:06 +11:00
daurnimator
0def92cff4
std: use enum literals in std.json 2019-12-30 23:47:33 +11:00
daurnimator
80d37a13c0
std: use a union(enum) for std.json.Token 2019-12-30 23:47:29 +11:00
daurnimator
17cc511ea4
std: fmt std/json.zig 2019-12-30 22:34:19 +11:00
Andrew Kelley
e0c7d12043
update std/json.zig to latest language changes
fixes regression from 54231e832bae780c5012fc5cd30932447f1e1d47
2019-12-29 19:00:27 -05:00
Andrew Kelley
54231e832b
Merge pull request #3648 from xackus/json-unescape
breaking: JSON unescape
2019-12-29 18:31:10 -05:00
Lachlan Easton
fe0e8c87b7 Tokenizer: Copy optional tokens prior to being set to null #3737 (#3910)
* Tokenizer: Copy optional tokens prior to being set to null #3737

* Add TODO comments, reminder to audit copying optional pattern.
2019-12-16 11:01:02 -05:00
Robin Voetter
4b4fbe3887
Replace @typeOf with @TypeOf in all zig source
This change was mostly made with `zig fmt` and this also modified some whitespace. Note that in some files, `zig fmt` produced incorrect code, so the change was made manually.
2019-12-10 11:09:41 -05:00
xackus
c27d06596b fix integers parsed as floats 2019-12-10 10:30:41 -05:00
Andrew Kelley
0237e7a701 std.io.getStdOut and related fns no longer can error
Thanks to the Windows Process Environment Block, it is possible to
obtain handles to the standard input, output, and error streams without
possibility of failure.
2019-11-13 04:01:40 +00:00
xackus
f9b7d6d75d Fix bugs in JSON parser
Make comments into documentation where appropriate
2019-11-11 23:25:54 +01:00
xackus
371747d8fb json: surrogate pair support
test json.Parser with tests used for json.Streaming parser
(some don't pass yet)
2019-11-11 22:06:00 +01:00
xackus
739f716108 minor fixes 2019-11-11 19:06:35 +01:00
xackus
f6d124418f Fix and document 2019-11-10 22:26:42 +01:00
xackus
6d0cdf7cd7 Unescape JSON strings 2019-11-10 22:05:03 +01:00
Andrew Kelley
e0db54e89d
update the codebase to use @as 2019-11-08 15:57:24 -05:00
Sebastian Keller
f81f36e2ff std.json.Value: added dumpStream(), utilize WriteStream for dump() 2019-11-06 18:21:52 -05:00
Sebastian Keller
dd4e9fb16b Fixed a leak in the json parser.
parseString() created a copy of the string using the wrong allocator.
Instead of using the ArenaAllocator, it was using the allocator passed
into Parser.init(). This lead to a leak as the copied string was not
freed when the ArenaAllocator was deinited.
2019-11-06 14:00:36 -05:00
Andrew Kelley
b37c009683
Merge pull request #3541 from xackus/language_server
* fix json parser crashing on empty input

* make implicit cast of tagged unions to enums easier to find in docs
2019-10-28 15:08:33 -04:00
xackus
36fa5fabc6 rename error and specify it in function 2019-10-27 21:52:28 +01:00
xackus
eeb6536c85
better test name for empty string
Co-Authored-By: Andrew Kelley <andrew@ziglang.org>
2019-10-27 21:41:52 +01:00
Sebastian Keller
78b00c0b51 Added test for 'emitJson' 2019-10-27 20:49:42 +01:00