-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
std/encoding/json: add dynamic decoding
- Loading branch information
1 parent
1219e1c
commit 62ae718
Showing
3 changed files
with
268 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2025 The Jule Programming Language. | ||
// Use of this source code is governed by a BSD 3-Clause | ||
// license that can be found in the LICENSE file. | ||
|
||
use "std/comptime" | ||
|
||
// Comptime type information for the dynamic JSON value types. | ||
const valueT = comptime::TypeOf(Value) | ||
const objectT = comptime::TypeOf(Object) | ||
const arrayT = comptime::TypeOf(Array) | ||
const boolT = comptime::TypeOf(Bool) | ||
const numberT = comptime::TypeOf(Number) | ||
const stringT = comptime::TypeOf(String) | ||
|
||
// Dynamic JSON value type. | ||
// Can store any JSON value. | ||
enum Value: type { | ||
Object, | ||
Array, | ||
Bool, | ||
Number, | ||
String, | ||
} | ||
|
||
// Dynamic JSON object type. | ||
type Object: map[str]Value | ||
|
||
// Dynamic JSON array type. | ||
type Array: []Value | ||
|
||
// Dynamic JSON boolean type. | ||
type Bool: bool | ||
|
||
// Dynamic JSON number type. | ||
type Number: f64 | ||
|
||
// Dynamic JSON string type. | ||
type String: str |