-1

I know many thread for json to c# is available but i did not get my answer as many JSON to C# method i had tried but not able to get out put for below json data in to string array in asp.net c#

"{\"jsonrpc\": \"2.0\", \"result\": {\"status\": \"Unknown\", \"amount (BTC)\": \"0.00000025\", \"memo\": \"\", \"address\": \"17EVqepvcF8nSuebwnqRcSHw2QcdBdqmrt\", \"URI\": \"bitcoin:17EVqepvcF8nSuebwnqRcSHw2QcdBdqmrt?amount=0.00000025\", \"amount\": 25, \"exp\": 86400, \"time\": 1503742971, \"id\": \"f62c82019e\"}, \"id\": \"123\"}"
L.B
  • 114,136
  • 19
  • 178
  • 224
Ashish
  • 83
  • 1
  • 4
  • 1
    Your question is unclear. You want to deserialize posted JSON into an array in ASP.net? – Anis Alibegić Aug 26 '17 at 10:39
  • Your json is not valid. either it is what you see in debugger window or your object is serialized two times. `object=>jsonstring=>escaped_jsonstring` – L.B Aug 26 '17 at 11:07

1 Answers1

2

Assuming that you pasted it correctly, that's not valid JSON. The quotes are escaped. If you un-escape them, everything parses correctly. I stuck your JSON in to a JavaScript string (which I could do thanks to the escaping), and then JSON.stringified it back to valid JSON (nicely formatted too):

{
    "jsonrpc": "2.0",
    "result": {
        "status": "Unknown",
        "amount (BTC)": "0.00000025",
        "memo": "",
        "address": "17EVqepvcF8nSuebwnqRcSHw2QcdBdqmrt",
        "URI": "bitcoin:17EVqepvcF8nSuebwnqRcSHw2QcdBdqmrt?amount=0.00000025",
        "amount": 25,
        "exp": 86400,
        "time": 1503742971,
        "id": "f62c82019e"
    },
    "id": "123"
}

You should look at either your source of JSON or if there are any transformations you're doing upon it.

Dawson Toth
  • 5,580
  • 2
  • 22
  • 37
  • Then do the `dynamic data = Json.Decode(json);` or create the class(es) and deserialize using Newtonsoft Json. [SAME QUESTION](https://stackoverflow.com/questions/25052293/deserialize-json-to-c-sharp-classes). @Ashish – Anis Alibegić Aug 26 '17 at 10:41