Commit Graph

180 Commits

Author SHA1 Message Date
Neirokan
8cdf7ade48 encoding/json: clone unquoted strings 2025-11-06 19:24:58 +03:00
Jeroen van Rijn
236111864e Link doc lines to source specifications. 2025-10-10 18:29:52 +02:00
Jeroen van Rijn
ece213afca Render examples. 2025-10-10 12:24:28 +02:00
Jeroen van Rijn
7a9ea3ee6d Further overhaul of package line comments. 2025-10-09 23:05:29 +02:00
Jeroen van Rijn
288b45f50c package lines for encoding 2025-10-09 16:34:18 +02:00
Courtney Strachan
69ad94d8a8 Followup fix to #4895 2025-10-05 19:22:04 -07:00
Courtney Strachan
6de2d6e8ca Merge branch 'odin-lang:master' into master 2025-10-06 02:41:44 +01:00
gingerBill
af3184adc9 Change is_utf16 field to encoding and use an enum 2025-08-05 15:12:54 +01:00
gingerBill
ae02d3d02d Begin supporting string16 across the core library 2025-08-02 11:55:16 +01:00
Feoramund
b7de15caa3 Clarify strconv.append_* to strconv.write_* 2025-06-05 16:56:00 -04:00
Laytan
d3159f74cd Merge pull request #4944 from dozn/master
[core:encoding/json] When Unmarshalling, Only Match On Struct Tags If Present
2025-05-15 22:31:34 +02:00
Ely Alon
13566306d2 Fix typo in private function 2025-04-28 22:03:20 +03:00
Laytan Laats
e4bc9677af fix unmarshalling bit sets in json
Fixes #4761
2025-03-22 00:20:00 +01:00
dozn
3148acf6a6 [core:encoding/json] When Unmarshalling, Only Match Struct Tags If Present 2025-03-17 01:51:04 -07:00
Courtney Strachan
dbbe96ae5c Fixed json null value parsing 2025-03-02 07:57:23 -08:00
jkenda
51b80c5a20 encoding/json: marshal enumerated arrays to objects with key-value pairs 2025-02-01 10:32:07 +01:00
dozn
87c159c69f Remove unnecessary string() conversion. 2024-12-28 08:13:38 -08:00
dozn
d22cb20d85 Use Struct Tags For Embedded (with using) Structs When Unmarshalling JSON
A fix for https://github.com/odin-lang/Odin/issues/4539
2024-12-28 07:48:09 -08:00
Laytan Laats
7edd332993 fix #4536 - stack buffer overflow for size_of 0 types in struct unmarshal 2024-12-06 22:12:52 +01:00
gingerBill
e4bdc4ff7c Merge pull request #4562 from dozn/patch-1
Move Struct Field Zipping Outside of Loop
2024-12-06 14:21:01 +00:00
gingerBill
d452d37b93 Fix #4537 2024-12-05 15:51:05 +00:00
dozn
37fb2754a1 Move Struct Field Zipping Outside of JSON Token Loop 2024-12-05 07:23:34 -08:00
gingerBill
d0f87913e2 Fix #4549 2024-12-02 10:49:49 +00:00
o:tone
c3478e0002 fix unmarshal unhandled error (#4515)
* fix unmarshal unhandled error
2024-11-25 13:15:33 +01:00
gingerBill
26f6741674 Check for more errors in json.unmarshal 2024-11-14 16:45:36 +00:00
gingerBill
c440122d93 Remove relative types from json marshaller 2024-11-14 16:18:41 +00:00
Laytan Laats
e79f94ca5e encoding/json: fix leak when string is unmarshalled into non-string field
Fixes #4391
2024-10-19 17:08:24 +02:00
jakubtomsu
7487d507be unmarshal bitset ints like cbor does 2024-09-04 11:08:45 +02:00
Jeroen van Rijn
fc5ce30f34 Allow json to unmarshal empty struct. 2024-07-21 00:37:11 +02:00
gingerBill
02408b713a Merge pull request #3910 from VladPavliuk/json-add-int-key-map-support
Allow to `marshal` and `unmarshal` maps with int keys
2024-07-14 22:00:01 +01:00
gingerBill
399c3ab067 Reduce the size of runtime.Type_Info 2024-07-14 21:37:35 +01:00
VladPavliuk
3f8712edb0 Merge branch 'master' into json-add-int-key-map-support 2024-07-14 18:22:20 +03:00
VladPavliuk
76fe5d1346 Align ignore syntax of json tags with fmt, cbor 2024-07-14 00:21:05 +03:00
VladPavliuk
64ae99f016 Add support of ignore tag for json.marshal 2024-07-13 14:13:59 +03:00
VladPavliuk
dbdad0476d Allow to marshal and unmarshal maps with int keys 2024-07-13 00:07:48 +03:00
gingerBill
e296d6fb90 Fix loads of indentation issues with mixing spaces and tabs 2024-06-29 19:50:51 +01:00
korvahkh
104ca2ce22 Merge branch 'odin-lang:master' into fix-omitempty-comma 2024-06-13 01:27:44 +00:00
Jeroen van Rijn
601df0e8f7 Port tests\core\encoding\json 2024-06-02 14:47:08 -04:00
korvahkh
a7a6ff8c69 encoding/json: Fix struct marshal() emitting comma after omitted field
Previously:
```odin
package main

import "core:fmt"
import "core:encoding/json"

T :: struct {
	a: string `json:",omitempty"`,
	b: string,
}

main :: proc() {
	data, _ := json.marshal(T{b = "foo"})
	fmt.println(string(data))
}
```
would output:
```
{,"b":"foo"}
```

which is not correct.

Also cleaned up some whitespace while I'm at it.
2024-05-27 16:59:46 -05:00
IllusionMan1212
65a4a56a83 fix(core/encoding/json): remove Unsupported_Type return when marshalling bit_set 2024-05-25 00:45:30 +02:00
korvahkh
9b759f39fc encoding/json: Properly marshal #no_nil unions
Previously the first variant of a `#no_nil` would always be output as
`null`, and following variants would be treated as the wrong type.
2024-05-11 14:36:56 -05:00
Feoramund
309a770cbf Fix omitempty in json.marshal 2024-04-27 05:24:59 -04:00
gingerBill
334e08c750 Update numerous package declaration names 2024-04-18 12:17:39 +01:00
gingerBill
fd487f66bc Add json:"name,omitempty" 2024-04-10 13:40:25 +01:00
gingerBill
d0dc7395e9 Allow for comma-separate json names json:"name,flag" 2024-04-10 13:29:10 +01:00
Laytan Laats
3a0df80066 correct newly found vets 2024-04-03 00:52:58 +02:00
Franz Höltermann
a422aba578 Json: improved unmarshalling of using _: T fields.
`using _: T` fields will now have their members unmarshalled to their
parent types reflecting the new behaviour of json.marshall.

Example:
```go
A :: struct {
    using _: B,
}

B :: struct {
    field: string,
}

data := `{"field": "Hello World"}`

a: A
json.unmarshal_string(data, &a)
```
2024-03-27 15:46:44 +01:00
Franz Höltermann
92a5666c1c Json: fields on structs like 'using _: T' will now have T's fields
marshalled directly into the parent type without an '"_":{ ... }'.
This seems like desirable behavior to me, since you can't access the
fields with 'Parent_Type._.field' either.
2024-03-26 20:22:51 +01:00
gingerBill
c05a92ab3e Merge pull request #3215 from blob1807/json-better-enum-support
core:encoding/json Add support for writing enum value names
2024-03-06 14:56:19 +00:00
gingerBill
8d496dc3d0 Fix #3173 2024-03-06 14:51:56 +00:00