-3

我有:

[
  {
    "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"];

返回错误

4

2 回答 2

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"]);

希望能帮助到你。干杯

于 2012-11-10T18:30:34.350 回答
1

SoapHexBinary在命名空间中使用System.Runtime.Remoting.Metadata.W3cXsd2001

var jArr = JArray.Parse(json);
var hex = SoapHexBinary.Parse((string)jArr[0]["txid"]);
byte[] buf  = hex.Value;
于 2012-11-10T19:31:42.793 回答