JSON(JavaScript Object Notation)javascript对象表示法。也是存储和交换文本信息的语法。由于在EOS中大量应用,比如区块格式,ABI文件.......,初步的了解对于EOS的学习有很大的帮助。
详细内容:http://www.w3school.com.cn/json/json_syntax.asp
EOS issue动作,交易(JSON)格式
{
"expiration": "2018-12-08T21:18:01",
"ref_block_num": 32100,
"ref_block_prefix": 1252316989,
"max_net_usage_words": 0,
"max_cpu_usage_ms": 0,
"delay_sec": 0,
"context_free_actions": [],
"actions": [{
"account": "eosio.token",
"name": "issue",
"authorization": [{
"actor": "eosio",
"permission": "active"
}
],
"data": "0000000000000e3d40420f0000000000044e420000000000046d656d6f"
}
],
"transaction_extensions": [],
"signatures": [
"SIG_K1_KYct9wbZKGcTcWW8FmBi5K3nuiU4NSPuBM48dyL7rMbenszvS8FaCctXHdPftYjJCpPXBxjjaagXVeGUAJsVrfcvpzp8fk"
],
"context_free_data": []
}
1.jSON语法规则
json对象:
从issue 的交易格式,以"{“开始和以”}“结尾,里面包含:名称(KEY)/值对(VALUE),中间用” :"隔开。
"expiration": "2018-12-08T21:18:01",
JSON 值可以是:数字(整数或浮点数)字符串(在双引号中)
逻辑值(true 或 false)数组(在方括号中)对象(在花括号中)
null
例:
{
"expiration": "2018-12-08T21:18:01",
"ref_block_num": 32100,
"ON" : fasle,
"money": 10.00,
}
b.数组
数组中可包含多个对象。
"actions": [{
"account": "eosio.token", //关键字:账号 ,键值:eosio.token
"name": "issue", //关键字:动作的名称 ,键值:issue(发行)
"authorization": [{ "actor": "eosio" , "permission": "active" } ],
//数组名:授权,数组成员 {关键字:执行者 键值:账户名 关键字权限:键值:active
"data": "0000.....420000000000046d656d6f "
} ],
这个action数组中包含三对键值对: “account”: “eosio.token”,“name”: “issue” ,“data”: "0000…420000000000046d656d6f "和一个授权数组: “authorization”: [{ “actor”: “eosio”,“permission”: “active”}],
通过这些键值与授权数组描述了issue动作。
2.javascrip调用
将对象序列化成JSON格式
var person = {
firstname:"Tom",
lastname:"Gates",
age:56,
address:"USA",
classmates:['xiaoming','xiaozhang','李磊']
};
var x = JSON.stringify(person);
//var x = JSON.stringify(xiaoming, null, ' '); //缩进输出
console.log(x)
输出:
{"firstname":"Tom","lastname":"Gates","age":56,"address":"USA","classmates":["xiaoming","xiaozhang","李磊"]}
var issue = {
"expiration": "2018-12-08T21:18:01",
"ref_block_num": 32100,
"ref_block_prefix": 1252316989,
"max_net_usage_words": 0,
"max_cpu_usage_ms": 0,
"delay_sec": 0,
"context_free_actions": [],
"actions": [{
"account": "eosio.token",
"name": "issue",
"authorization": [{
"actor": "eosio",
"permission": "active"
}
],
"data": "0000000000000e3d40420f0000000000044e420000000000046d656d6f"
}
],
"transaction_extensions": [],
"signatures": [
"SIG_K1_KYct9wbZKGcTcWW8FmBi5K3nuiU4NSPuBM48dyL7rMbenszvS8FaCctXHdPftYjJCpPXBxjjaagXVeGUAJsVrfcvpzp8fk"
],
"context_free_data": []
}
3.文件格式.json