mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-01-11 01:20:37 +00:00
compiler: support System.Json.*
syscalls
This commit is contained in:
parent
6339efac11
commit
becb8a0f72
2 changed files with 32 additions and 0 deletions
|
@ -10,6 +10,10 @@ var syscalls = map[string]map[string]string{
|
||||||
"Next": "System.Enumerator.Next",
|
"Next": "System.Enumerator.Next",
|
||||||
"Value": "System.Enumerator.Value",
|
"Value": "System.Enumerator.Value",
|
||||||
},
|
},
|
||||||
|
"json": {
|
||||||
|
"Serialize": "System.Json.Serialize",
|
||||||
|
"Deserialize": "System.Json.Deserialize",
|
||||||
|
},
|
||||||
"storage": {
|
"storage": {
|
||||||
"ConvertContextToReadOnly": "System.Storage.AsReadOnly",
|
"ConvertContextToReadOnly": "System.Storage.AsReadOnly",
|
||||||
"Delete": "System.Storage.Delete",
|
"Delete": "System.Storage.Delete",
|
||||||
|
|
28
pkg/interop/json/json.go
Normal file
28
pkg/interop/json/json.go
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
Package json provides various JSON serialization/deserialization routines.
|
||||||
|
*/
|
||||||
|
package json
|
||||||
|
|
||||||
|
// ToJSON serializes value to json. It uses `System.Json.Serialize` syscall.
|
||||||
|
// Serialization format is the following:
|
||||||
|
// []byte -> base64 string
|
||||||
|
// bool -> json boolean
|
||||||
|
// nil -> Null
|
||||||
|
// string -> base64 encoded sequence of underlying bytes
|
||||||
|
// (u)int* -> integer, only value in -2^53..2^53 are allowed
|
||||||
|
// []interface{} -> json array
|
||||||
|
// map[type1]type2 -> json object with string keys marshaled as strings (not base64).
|
||||||
|
func ToJSON(item interface{}) []byte {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FromJSON deserializes value from json. It uses `System.Json.Deserialize` syscall.
|
||||||
|
// It performs deserialization as follows:
|
||||||
|
// strings -> []byte (string) from base64
|
||||||
|
// integers -> (u)int* types
|
||||||
|
// null -> interface{}(nil)
|
||||||
|
// arrays -> []interface{}
|
||||||
|
// maps -> map[string]interface{}
|
||||||
|
func FromJSON(data []byte) interface{} {
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
Reference in a new issue