我有:
[
{
"account": "max",
"address": "1DjA7XoVkB8bKRzcf5oW2MFtyN92u3ssEu",
"category": "receive",
"amount": 0.1,
"confirmations": 290,
"blockhash": "000000000000040f883801bd432ae638258dd852e124f8db349a9a6afc0bd4
df",
"blockindex": 139,
"blocktime": 1352407188,
"txid": "cee56f0aa97f9200e7fcb220861098bd74419cf5427e81b02870cb9baf063560",
"time": 1352407188,
"timereceived": 1352550395
}
]
获取txid值的最快方法是什么?我一直在尝试组合几个小时。
编辑:它是一个JArray C#对象,看起来像这样:o = new JArray(o.First);
return o["txid"];
返回错误
答案 0 :(得分:1)
如果代码收到字符串,请尝试:
alert(eval('[{"account": "max","address": "1DjA7XoVkB8bKRzcf5oW2MFtyN92u3ssEu","category": "receive","amount": 0.1,"confirmations": 290,"blockhash": "000000000000040f883801bd432ae638258dd852e124f8db349a9a6afc0bd4
df","blockindex": 139,"blocktime": 1352407188,"txid": "cee56f0aa97f9200e7fcb220861098bd74419cf5427e81b02870cb9baf063560","time":1352407188,"timereceived": 1352550395}]')[0]["txid"]);
如果代码是javascript对象,请尝试以下方法:
var obj = [
{
"account": "max",
"address": "1DjA7XoVkB8bKRzcf5oW2MFtyN92u3ssEu",
"category": "receive",
"amount": 0.1,
"confirmations": 290,
"blockhash": "000000000000040f883801bd432ae638258dd852e124f8db349a9a6afc0bd4
df",
"blockindex": 139,
"blocktime": 1352407188,
"txid": "cee56f0aa97f9200e7fcb220861098bd74419cf5427e81b02870cb9baf063560",
"time": 1352407188,
"timereceived": 1352550395
}
];
alert(obj[0]["txid"]);
希望它有所帮助。 干杯
答案 1 :(得分:1)
在名称空间SoapHexBinary
System.Runtime.Remoting.Metadata.W3cXsd2001
var jArr = JArray.Parse(json);
var hex = SoapHexBinary.Parse((string)jArr[0]["txid"]);
byte[] buf = hex.Value;