78 Commits

Author SHA1 Message Date
John Burton
33c4ad7f3a Add missing std in dump function json.zig
Add missing std to use of std.io.getStdErr in the function dump
so that it compiles.
2020-10-20 13:39:38 +03:00
Tadeo Kondrak
771f35c593
Use less inefficient method of replacing TypeInfo.UnionField.enum_field 2020-09-07 06:23:27 -06:00
Tadeo Kondrak
ac19ccf595
Update standard library for removal of TypeInfo.UnionField.enum_field 2020-09-07 06:23:26 -06:00
Andrew Kelley
4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
Andrew Kelley
d159ba9295 zig fmt 2020-08-04 23:04:20 -07:00
daurnimator
978a38ee40 std: fix json parsing into unions 2020-07-24 20:35:47 +00:00
Vexu
e85fe13e44
run zig fmt on std lib and self hosted 2020-07-11 20:41:19 +03:00
Andrew Kelley
289eab9177
Merge pull request #5786 from ziglang/std-hash-map
reimplement std.HashMap
2020-07-05 21:12:20 +00:00
Andrew Kelley
632acffcbd update std lib to new hash map API 2020-07-05 21:11:42 +00:00
joachimschmidt557
0ae1157e45 std.mem.dupe is deprecated, move all references in std
Replaced all occurences of std.mem.dupe in stdlib with
Allocator.dupe/std.mem.dupeZ -> Allocator.dupeZ
2020-07-04 21:40:06 +03:00
prime31
65ef74e2cd
try allocation of pointer type when parsing (#5665)
* `try` allocation of pointer type when parsing

* fixes pointer destroy compile error
2020-06-22 17:30:02 +03:00
Andrew Kelley
da549a72e1 zig fmt 2020-06-20 18:39:15 -04:00
daurnimator
af592f0ddd
std: remove std.debug.getStderrStream
Rather than migrate to new 'writer' interface, just remove it
2020-06-15 23:51:25 +10:00
Dmitry Atamanov
0328537ca6
Support stringify for vectors (#5441)
* use array's pointer
2020-05-28 23:10:16 -04:00
Andrew Kelley
1cde0edff4 json: properly stringify error sets
I did this wrong originally in
feade9ef0010b1b47d7216e786ed964d09612c2b
2020-05-18 19:23:40 -04:00
Andrew Kelley
feade9ef00 std.json: support stringify for anyerror 2020-05-17 17:07:27 -04:00
Jason Merrill
706311cad9
Fix comment typo RFC8529 -> RFC8259
Ref: https://tools.ietf.org/html/rfc8259
2020-05-12 19:11:05 -07:00
Vexu
80d0c2f166
Merge pull request #5118 from xackus/fix-json-writestream
fix json.WriteStream.emitJson
2020-05-12 17:44:06 +03:00
Vexu
b1ebaba408
std.json properly handle comptime int/float 2020-05-12 15:15:21 +03:00
Josh Junon
b6dc7fc9ff
publicize member functions affected by #4909 2020-05-08 14:26:28 +03:00
Auguste Rame
0df82889cf
Fix issue with std.json incorrectly replacing forward slashes with a backslash (#5167)
* fix breaking typo in json.zig

* add tests
2020-04-27 12:22:43 -04:00
Timon Kruiper
c829f2f7b7 Add mips support to standard library 2020-04-24 15:28:55 -04:00
Vexu
b6fe839248
update std lib to decls being disallowed between fields 2020-04-18 23:56:05 +03:00
xackus
dbc00e2424 ArrayList: remove old (before span) API 2020-04-11 20:40:34 -04:00
Vexu
95fefcd4c9
fix broken tests 2020-04-07 16:56:48 +03:00
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