-3

I have:

[
  {
    "account": "max",
    "address": "1DjA7XoVkB8bKRzcf5oW2MFtyN92u3ssEu",
    "category": "receive",
    "amount": 0.1,
    "confirmations": 290,
    "blockhash": "000000000000040f883801bd432ae638258dd852e124f8db349a9a6afc0bd4
df",
    "blockindex": 139,
    "blocktime": 1352407188,
    "txid": "cee56f0aa97f9200e7fcb220861098bd74419cf5427e81b02870cb9baf063560",
    "time": 1352407188,
    "timereceived": 1352550395
  }
]

What is the quickest way to get the value of txid? I have been trying combinations for hours.

EDIT: It's a JArray C# object, looks like this:

o = new JArray(o.First);
return o["txid"];

returns an error

Max0999
  • 354
  • 4
  • 20

2 Answers2

1

If the code recieves as a string try this:

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

If the code is an javascript object try this one:

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

Hope it helps. Cheers

Rikki
  • 3,338
  • 1
  • 22
  • 34
1

Using SoapHexBinary in namespace System.Runtime.Remoting.Metadata.W3cXsd2001

var jArr = JArray.Parse(json);
var hex = SoapHexBinary.Parse((string)jArr[0]["txid"]);
byte[] buf  = hex.Value;
L.B
  • 114,136
  • 19
  • 178
  • 224