aboutsummaryrefslogtreecommitdiff
path: root/lib/std/json.zig
AgeCommit message (Collapse)Author
2022-07-24std.json: expose encodeJsonString and encodeJsonStringCharsJonathan Marler
Expose 2 functions from std.json. These functions take a slice of bytes and forward them to a given writer as a JSON encoded string. The use case I have for this is in a custom JsonStringWriter. This writer takes data and automatically encodes it as JSON string characters and forwards it to an underlying writer. I use this JsonStringWriter in combination with std.fmt.format to go directly from a format string/arg pair to JSON. This way I don't have to format my string into a separate buffer first and encode it afterwards, which avoids the need to create a temporary buffer to hold the unencoded but formatted string.
2022-07-23std.json: Fix parsing of large numbersominitay
Numbers greater than about 2^53 are encoded as strings in JSON. std.json.parseInternal previously errored out in this condition.
2022-07-07std.json: move tests to json/test.zig fileAndrew Kelley
This accomplishes two things: * Works around #8442 by putting stage1-specific logic in to disable all the std.json tests. * Slightly reduces installation size of zig since std lib files ending in "test.zig" are excluded from being installed.
2022-06-29std.json: Support disabling indent (#11823)May B
Newline Delimited JSON (ndjson) expect compact json without newline inside its content Add None to StringfyOptions.indent and move newline writeByte inside StringfyOptions.outputIndent
2022-06-03std: update tests to stage2 semanticsVeikka Tuominen
2022-05-10std.json stringify fix object keys are always is stringsAndreas Reischuck
* extracted outputJsonString to avoid code duplication
2022-05-10std.json add stringify struct with string as arrayOfekShochat
2022-04-27std: use float builtins instead of std.mathAndrew Kelley
2022-03-08std.json: correctly handle sentinel terminated slicesBenjamin San Souci
2022-03-08deprecated TypeInfo in favor of TypeJonathan Marler
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-02-13std.json: fix compile error for comptime fieldssharpobject
This is covered by an existing test which was already failing.
2022-02-01stage2: remove anytype fields from the languageAndrew Kelley
closes #10705
2022-01-17std: add json.stringifyAllocMeghan Denny
2021-11-30allocgate: renamed getAllocator function to allocatorLee Cannon
2021-11-30allocgate: std Allocator interface refactorLee Cannon
2021-11-30std lib API deprecations for the upcoming 0.9.0 releaseAndrew Kelley
See #3811
2021-11-16std/json: use bit-stack for nesting instead of large LLVM integer typeMarc Tiehuis
The stack has been adjusted so that instead of pushing to index 0 in the integer we push to the current end/index of the underlying integer. This means we don't require a shift for every limb after each push/pop and instead only require a mask/or and add/sub on a single element of the array. Fixes #5959.
2021-11-15Json Stringify option to not write out null optional fields (#8979)Chris Heyes
2021-11-09std.Thread.Mutex: change API to lock() and unlock()Andrew Kelley
This is a breaking change. Before, usage looked like this: ```zig const held = mutex.acquire(); defer held.release(); ``` Now it looks like this: ```zig mutex.lock(); defer mutex.unlock(); ``` The `Held` type was an idea to make mutexes slightly safer by making it more difficult to forget to release an aquired lock. However, this ultimately caused more problems than it solved, when any data structures needed to store a held mutex. Simplify everything by reducing the API down to the primitives: lock() and unlock(). Closes #8051 Closes #8246 Closes #10105
2021-09-19Update all ensureCapacity calls to the relevant non-deprecated versionRyan Liptak
2021-09-01std, compiler-rt: remove test names where applicableAndrew Kelley
Tests with no names are executed when using `zig test` regardless of the `--test-filter` used. Non-named tests should be used when simply importing unit tests from another file. This allows `zig test` to find all the appropriate tests, even when using `--test-filter`.
2021-09-01std: reorganization that allows new usingnamespace semanticsAndrew Kelley
The proposal #9629 is now accepted, usingnamespace stays but no longer puts identifiers in scope.
2021-08-24remove redundant license headers from zig standard libraryAndrew Kelley
We already have a LICENSE file that covers the Zig Standard Library. We no longer need to remind everyone that the license is MIT in every single file. Previously this was introduced to clarify the situation for a fork of Zig that made Zig's LICENSE file harder to find, and replaced it with their own license that required annual payments to their company. However that fork now appears to be dead. So there is no need to reinforce the copyright notice in every single file.
2021-08-20std.json: Add support for recursive objects to std.json.parse (#9307)Dmitry Matveyev
* Add support for recursive objects to std.json.parse * Remove previously defined error set * Try with function which returns an error set * Don't analyze already inferred types * Add comptime to inferred_type parameter * Make ParseInternalError to accept only a single argument * Add public `ParseError` for `parse` function * Use error.Foo syntax for errors instead of a named error set * Better formatting * Update to latest code changes
2021-07-19fix style warning in json.zigTizoner
2021-07-01std: Catch and handle overflow in json parserLemonBoy
When a floating-point value with no fractional part is shoved into an integer type we must check whether it fits or not before calling `@floatToInt` as the builtin panics in case of overflow. Catch the error and bubble it up to the caller.
2021-06-26allow json scientific notation to coerce to integers as long as they ↵Emil Lerch
actually resolve to int type
2021-06-21fix code broken from previous commitJacob G-W
2021-06-04Merge pull request #8750 from lithdew/masterAndrew Kelley
x/io, x/os: async i/o reactor, cross-platform socket syscalls and bits
2021-06-03Breaking hash map changes for 0.8.0Martin Wickham
- hash/eql functions moved into a Context object - *Context functions pass an explicit context - *Adapted functions pass specialized keys and contexts - new getPtr() function returns a pointer to value - remove functions renamed to fetchRemove - new remove functions return bool - removeAssertDiscard deleted, use assert(remove(...)) instead - Keys and values are stored in separate arrays - Entry is now {*K, *V}, the new KV is {K, V} - BufSet/BufMap functions renamed to match other set/map types - fixed iterating-while-modifying bug in src/link/C.zig
2021-06-01x/os: {read, write}Vectorized() -> {read, write}Message()Kenta Iwasaki
2021-05-31std.sync.atomic: extended atomic helper functions (#8866)protty
- deprecates `std.Thread.spinLoopHint` and moves it to `std.atomic.spinLoopHint` - added an Atomic(T) generic wrapper type which replaces atomic.Bool and atomic.Int - in Atomic(T), selectively expose member functions depending on T and include bitwise atomic methods when T is an Integer - added fence() and compilerFence() to std.atomic
2021-05-31std: by default, disallow trailing data when parsing jsondaurnimator
2021-05-31std: fix json.parse with 0 length arraysdaurnimator
2021-05-30std.json: update to new testing APIAndrew Kelley
2021-05-30std.json: option to ignore unknown fieldsEthan Gruffudd
Closes #7906
2021-05-20Run `zig fmt` on src/ and lib/std/Isaac Freund
This replaces callconv(.Inline) with the more idiomatic inline keyword.
2021-05-15Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * build.zig * src/Compilation.zig * src/codegen/spirv/spec.zig * src/link/SpirV.zig * test/stage2/darwin.zig - this one might be problematic; start.zig looks for `main` in the root source file, not `_main`. Not sure why there is an underscore there in master branch.
2021-05-14fix logic for duplicate comptime fields and avoid freeing comptime fields in ↵Matthew Borkowski
parseFree and parseInternal
2021-05-13fix duplicate_field_behavior UseFirst in json.zigMatthew Borkowski
2021-05-13std/json: Fix premature closing brace being considered valid JSONMatthew Borkowski
return error from StreamingParser when reading closing brace when expecting value for an object key
2021-05-12Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * lib/std/os/linux.zig * lib/std/os/windows/bits.zig * src/Module.zig * src/Sema.zig * test/stage2/test.zig Mainly I wanted Jakub's new macOS code for respecting stack size, since we now depend on it for debug builds able to pass one of the test cases for recursive comptime function calls with `@setEvalBranchQuota`. The conflicts were all trivial.
2021-05-11std/json: fix previous commit for std.testing changesIsaac Freund
2021-05-11fix a double free in parse when duplicate_field_behavior is UseLast and a ↵Matthew Borkowski
leak in parse when allocating a single item
2021-05-08Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * doc/langref.html.in * lib/std/enums.zig * lib/std/fmt.zig * lib/std/hash/auto_hash.zig * lib/std/math.zig * lib/std/mem.zig * lib/std/meta.zig * test/behavior/alignof.zig * test/behavior/bitcast.zig * test/behavior/bugs/1421.zig * test/behavior/cast.zig * test/behavior/ptrcast.zig * test/behavior/type_info.zig * test/behavior/vector.zig Master branch added `try` to a bunch of testing function calls, and some lines also had changed how to refer to the native architecture and other `@import("builtin")` stuff.
2021-05-08std: update usage of std.testingVeikka Tuominen
2021-04-22std: fix compile errors caught by stage2 AstGenAndrew Kelley
* `comptime const` is redundant * don't use `extern enum`; specify a tag type. `extern enum` is only when you need tags to alias. But aliasing tags is a smell. I will be making a proposal shortly to remove `extern enum` from the language. * there is no such thing as `packed enum`. * instead of `catch |_|`, omit the capture entirely. * unused function definition with missing parameter name * using `try` outside of a function or test
2021-04-04Switch std.json to use an ordered hashmapLewis Gaul
2021-02-27HashMap.put returns !void, not a !booldaurnimator
2021-02-21replace ArrayList.shrinkAndFree by ArrayList.shrinkRetainingCapacityBenjamin Graf