feat(tvix/eval): Implement builtins.fromJSON
Using `serde_json` for parsing JSON here, plus an `impl FromJSON for Value`. The latter is primarily to stay "dependency light" for now - likely going with an actual serde `Deserialize` impl in the future is going to be way better as it allows saving significantly on intermediary allocations. Change-Id: I152a0448ff7c87cf7ebaac927c38912b99de1c18 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6920 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
277c69cbe5
commit
5eb89be682
12 changed files with 123 additions and 13 deletions
23
tvix/eval/src/tests/tvix_tests/eval-okay-fromjson.nix
Normal file
23
tvix/eval/src/tests/tvix_tests/eval-okay-fromjson.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
[
|
||||
# RFC 7159, section 13.
|
||||
(builtins.fromJSON
|
||||
''
|
||||
{
|
||||
"Image": {
|
||||
"Width": 800,
|
||||
"Height": 600,
|
||||
"Title": "View from 15th Floor",
|
||||
"Thumbnail": {
|
||||
"Url": "http://www.example.com/image/481989943",
|
||||
"Height": 125,
|
||||
"Width": 100
|
||||
},
|
||||
"Animated" : false,
|
||||
"IDs": [116, 943, 234, 38793, true ,false,null, -100],
|
||||
"Latitude": 37.7668,
|
||||
"Longitude": -122.3959
|
||||
}
|
||||
}
|
||||
'')
|
||||
(builtins.fromJSON ''{"name": "a", "value": "b"}'')
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue