Удалить дополнительный текст из JSON - PullRequest
0 голосов
/ 07 ноября 2019

После получения ответа JSON я взял определенную часть и попытался десериализовать.

Ошибка:

После завершения чтения содержимого JSON обнаружен дополнительный текст: ". Path '', строка 1, позиция 6604.

Транзакция. cs - я сгенерировал этот класс через json2csharp.com.

using System.Collections.Generic;

public class Key
{
    public int amount { get; set; }
    public List<int> key_offsets { get; set; }
    public string k_image { get; set; }
}

public class Vin
{
    public Key key { get; set; }
}

public class Target
{
    public string key { get; set; }
}

public class Vout
{
    public int amount { get; set; }
    public Target target { get; set; }
}

public class EcdhInfo
{
    public string amount { get; set; }
}

public class RctSignatures
{
    public int type { get; set; }
    public int txnFee { get; set; }
    public List<EcdhInfo> ecdhInfo { get; set; }
    public List<string> outPk { get; set; }
}

public class Bp
{
    public string A { get; set; }
    public string S { get; set; }
    public string T1 { get; set; }
    public string T2 { get; set; }
    public string taux { get; set; }
    public string mu { get; set; }
    public List<string> L { get; set; }
    public List<string> R { get; set; }
    public string a { get; set; }
    public string b { get; set; }
    public string t { get; set; }
}

public class MG
{
    public List<List<string>> ss { get; set; }
    public string cc { get; set; }
}

public class RctsigPrunable
{
    public int nbp { get; set; }
    public List<Bp> bp { get; set; }
    public List<MG> MGs { get; set; }
    public List<string> pseudoOuts { get; set; }
}

public class RootObject
{
    public int version { get; set; }
    public int unlock_time { get; set; }
    public List<Vin> vin { get; set; }
    public List<Vout> vout { get; set; }
    public List<int> extra { get; set; }
    public RctSignatures rct_signatures { get; set; }
    public RctsigPrunable rctsig_prunable { get; set; }
}

Код

public string[] GetTransactionHashFromBlock (string height) {
        var str = "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"get_block\",\"params\":{\"height\":" + height + "}";

        var httpWebRequest = (HttpWebRequest) WebRequest.Create ("http://127.0.0.1:18081/json_rpc");
        httpWebRequest.ContentType = "application/json";
        httpWebRequest.Method = "POST";

        using (var streamWriter = new StreamWriter (httpWebRequest.GetRequestStream ())) {
            string json = str;
            streamWriter.Write (json);
        }
        string result;
        var httpResponse = (HttpWebResponse) httpWebRequest.GetResponse ();
        using (var streamReader = new StreamReader (httpResponse.GetResponseStream ())) {
            result = streamReader.ReadToEnd ();
        }

        var x = result.ToString ();

        string block = x.Replace ("\\n", string.Empty).Replace ("\\", "");

        String s1 = block.Substring (block.IndexOf ("\"tx_hashes\":") + 12);
        string s2 = s1.Trim ().Substring (s1.IndexOf ("\"tx_hashes\":"));
        string s3 = s2.Remove (0, 13);
        string final = "";

        foreach (var f in s3) {
            if (f == ']') {
                final = s3.Remove (s3.IndexOf (f));
            }
        }

        string[] tx_hashes = final.Split (',');
        foreach (var s in tx_hashes) {
            System.Console.WriteLine (s);
        }

        return tx_hashes;
    }

    [Route ("coin/gettx/{tx_hash}")]
    public string GetTransactionDetails (string tx_hash) {
        //get_transactions
        var tx_str = "{\"txs_hashes\":[\"" + tx_hash + "\"],\"decode_as_json\":true}";

        var httpWebRequest = (HttpWebRequest) WebRequest.Create ("http://127.0.0.1:18081/get_transactions");
        httpWebRequest.ContentType = "application/json";
        httpWebRequest.Method = "POST";

        using (var streamWriter = new StreamWriter (httpWebRequest.GetRequestStream ())) {
            string json = tx_str;
            streamWriter.Write (json);
        }
        string result;
        var httpResponse = (HttpWebResponse) httpWebRequest.GetResponse ();
        using (var streamReader = new StreamReader (httpResponse.GetResponseStream ())) {
            result = streamReader.ReadToEnd ();
        }

        var x = result.ToString ();

        var jsonstr = x.IndexOf ("\"txs_as_json\":");
        //s2 - JSON RESPONSE IS STORED HERE
        string s2 = x.Trim ().Substring (jsonstr);
        s2 = s2.Remove (0, 16);
        s2 = s2.Replace ("\\n", "");
        s2 = s2.Replace ("\\", "");

        s2 = s2.Remove (0, 1);
        System.Console.WriteLine(s2);



        RootObject tr = JsonConvert.DeserializeObject<RootObject> (s2);
        System.Console.WriteLine(tr);
        System.Console.WriteLine("VIN : ",tr.vin);
        System.Console.WriteLine ("EXTRA:",tr.extra);

        return s2;

    }

Проблема в том, что ответ JSON не может быть десериализован, поскольку в конце есть дополнительные символы.

В частности, те, которые выделены на скриншоте: enter image description here

РЕДАКТИРОВАТЬ: ПОЛНЫЙ JSON - До того, как я обрезал его

{
"status": "OK",
"txs": [{
"as_hex": "02000202000bc8f1f10497f859c8943d909d05da97088b8c01c315b80de91aef01ee0264222dc3ca132cd4bbba26fa89ac1fee71b1f7812be8ee39c6d05b8b2bc25fc202000b90dfb2058db308b779d2bd4cb28406d58302ec9d05c5239b4d8d4c993b4889fdf95d1b1a20598a62cea7dcfcbc7f427e28227ff11cb62fc9ddffa08c88020002e58ac5597c76995e969a3681e7aeaf960ed669f7da602fe862052dbd845ec12e00023c379e3828d80b070032d185ca89d44d8c6c3d61da13e4c7e59b855a48dbaa3a2c016c6d3f4eb6931f0d3ffb74d5965c239d3537b6a018ce9f8360a01493a23d9f4b020901d6d12b7771da12ed04d0d7af1283feb6f4af3c4cf191518b4fed271728abd6db3824bfc3a907a87672cd7163285d7a1d54b9505128edfcf29304952d74799920cd42c33dd35217f8821a0bafe79655a17fdcdc22df7c0beedbb26463cd01c106bd65dd94eedcfdc9c656ad95913f0b82db3fc91fa02c149fd3c6fc81d61c4432845d27bc075ba7ac2bf6feeb405709996a027e2ed33d6f395fea5ffc9ed1d7a497742c6cd3da9645bef4e96c2c567528a2b154a58ed77778faac86e756134ad435b3a2736e8bec176d56a10fbbe7a8095ed1ac59c13b7464a50aa475555dd6721a158e079d31b3acb5ad2d37fbd42b7d8808bf6bfcf1b8be5664b78973092eef2a2439b3a6c1755d485ccc5ca0cfdff5be1acb419e2b92066bda3919e40b07d3bf9d60ed13cd85e497e1ba847bbf0c1ebad703273058830d1116e0d5eae17c7767aad8c0dec42ac03986a21ea32b109048b84b8d92fcfebdc85e8ad78adbcd0453fe8182411e5abba283d4f5a733e690151b5b2e0baf47d98679816990994fe3e08866bb5a25061d763bc24e756804021746f81fc053a1dca0b0311da9e0c9a14bb7c22043f8b4a42cb15009013dcb9c8086f5c0babac8ba4ea9da5488e2d740ae6fff2d13d797e49741269556aa7bdea8521d675b92a53a844e428e26fb65a667ef144e4f776a3fd4f823d3ade8f9ab98bb8b7163bc8af79e667f777b24b507ee154acdfbdf5ab2fc617d081547fb3bbb3bf63ff51526fe51915a65cb5d38be5f2ca197ccb7ca8dcdf10c066f9f6877ec28a5f80239b87ad1f9fed89b33d30584fa8082f9d4ca505762076b81ccf16299b0c61556fffc86369e630eb612bb324b714df5f14fb63d99b48351ed8d9ffd278ad58b6a1bfed4141d9564a37d3064006103d7448aa26e9772e658e9c1e475328920fcc27a079616d3a912e0f0d2d0d2b268884c85c439b9cb2c7b7916d185c76499c2709e59e28b6893f95ae8737f1751194a9e22f8a19744dda61c7b399383d20ce7297f6131d77b98d84d5f0889662f242013d7d0228cf22376d62a7d90519c05f1c27d15426ea5049a4cf8a801223bb8b7f368b1e12b31395b702e48f6987281d20d2d8d177aa1c76d93d7ed079b7ab768ad2d64ee840c92801190d8ff63e0c6b18e312854ffbdfb782836120c4e584539e647667ea0302d333380347efaa1e0b838dcf6d88d4df7c7a35b2d03c0019ed466c82c3a1faf82a552d7e410360b4fd0462028ac6af371b6f45b080c4eb169012f0d25f518d37202aaf510ca4b50367fa8f1c5bfa2ec212d22f09a064986ee31787f36ba85c63815a4f893bf529da02e86e8a82a18537ea6a4eef6002ae49225b63a6b8fd2bcb0114de24363c5407edeb8b87f5652d5030e7dead00490e482416b39cc4f9c8e167de280312e7326abd16fbafd9ef453ea926136d40dae8eb2cff90c4bfafd38e6bbec4781b5b522eb75985897480181c2c2b4fa3f03acd95ace580bc01ebba09c113c607d72a34a76982fc6c460df79b80e2b5af60cd9678780d6a4df6004126351b241fbd0c557839c9613676095a792ffc9cecd047ae5db4f77da9022a22c709ded46d12a3b23764d6f33991dcc7cf8442c3e2d08cce8c876488f2e0388f00c7cc9d245b92b874d5e336c373d29f18ab4939ffa04bb11825cb13296e524a2f1c93a5c9f9c747a3c0caa7df3e8f3a0cfdd92da2d050e98c6e8ca5d4288560afcaf1e2da64378fbb0b2b33dee63b960b18fe654d10021151e9135bf98a42a2be553a4fe87c7ee672033d138b1fc3bde25ea7d6410018056b853a0f8c42195f93910dc21769568bfdc7d1c27e7e2472b07388abead0cbdf38f57e0e0588ec2e59744ed50e6f7242f210069cf2440ec481743795f9d067b82e4cfbf5a8bb750f30954a66536cfe2cb104aad79efa1181030f273f1f90966bf95f614b01ae9a2d78596c9867ec0a9f6f91f77a62ad57af31c9c190d0d09a82e64995039a34bd595d4d5e590534735be64fbda980fbe564fd590d45ced016cb48349d7c0dfeaa2f85996b085e9ba0dd30274077e01ab95294e6a09ee810e8563cf3c605235bb9cd299e5a9d76f931a95402a793c8e9cf8ec7e43e3a3820af9e9078679736266aaa56691725a34c74d642e35e01a1dd868ca9a41b15e9700d27fd2e412bed674a9b861bc7b0ce5148c0994fd7b115fa09f91ff1f9e44300fbadbaa022739ad376bf66c7ff7c7a5939dab9b5086e123820a6371364345e901f5e3a2c1157b6a9a4bc3474f73cdcedb19419c93913cba5a4efaebc9ee0f210d201701983eeaf15a8ebc13032bcabca969ec3ed503026c0aebf927806d896d0c920d9905f43d3b6bef199899e25202e03ccd1ff38600629f2d44fe87e2ad66072fd0378a2b9f9fc63fdcd0c48cdd18e4060de808d1c91a5a335f01e211493407a090f4901b919896b3a27ca32c340c0e4342e4d16e677f8ebe32fc4d175aca0d88b6fd69f369b51b450aeb372b31eb4efe8bce9f9659138ad29510b0e13c25067bd75e8993da85a1608643a22d015ea83c5d936c7d8d928017e65e7dc5f97607adb21a130e00f36563eb359617388e6008b28ec88665cd4daac40277b1463d044f8c49f89feaed84eee3ac809d4351bdf4dd93911cc35a40289d18ccd3feb8025e0f5d502460d979f1b9243ee4d0bef18caaa2955c46eafa3982a986a50a470a6e75a452e2e9990ff58805955a37399efb85c5134bad6b39640f405ce3e5af0ff7afef22ce1a4e645e6dfe1a468c1f173286c9f6feacef1bbefe1cb982bfe502315fc0a31f3ec939f877dedc2943182338dc78dc5830f545e545da8041cbe30f0d37190d3049bef5a07f3bc3f2d31c22ca34b14f6a0def500ef6c3c75501220f2a4ae97bf8a0415da1cfd2a25dab8e9f978245ad724061484f903f64ce751d0d4b0b43068b11fc85d85c64d9de73f630e0d183744f64f9778d638bb34493010400ec7f91ea6c003e69a474c38339d43dc42455fad8219134a6610ee1c5e64702e477cbf3c5d0bca539d57cc2606c96c1cffd10f919e5580949f9361f7c1c2c0ed5e5f0c65ebeca71466d67f7f93c860c5919bd73cab0c7245428f1895c023d049723ebdf6e50253688ce52789230784a50289d92dbbced903f28f8bbab66250d8ebb3da0b5311b5650f72881b5856a70324598174713cb7fc1a508db46944a09d10590aa918d70524c208734b46c58d03f62371c8db3fe4f2561feac42625d000146403b8a65a08bf717dbc5c584c1d8d3805466ac04f26cea95727f8de6d9ba986cde3b94bd0f22624ab56ac711c13cca5935078d2d97bcb2a62692a7796ddc",
"as_json": "{\n  \"version\": 2, \n  \"unlock_time\": 0, \n  \"vin\": [ {\n      \"key\": {\n        \"amount\": 0, \n        \"key_offsets\": [ 10254536, 1473559, 1002056, 85648, 134106, 17931, 2755, 1720, 3433, 239, 366\n        ], \n        \"k_image\": \"REMOVED IT BECAUSE OF POST LIMITATIONS\"\n      }\n    }, {\n      \"key\": {\n        \"amount\": 0, \n        \"key_offsets\": [ 11317136, 137613, 15543, 1253074, 98866, 33237, 85740, 4549, 9883, 9741, 7577\n        ], \n        \"k_image\": \"REMOVED IT BECAUSE OF POST LIMITATIONS\"\n      }\n    }\n  ], \n  \"vout\": [ {\n      \"amount\": 0, \n      \"target\": {\n        \"key\": \"REMOVED IT BECAUSE OF POST LIMITATIONS\"\n      }\n    }, {\n      \"amount\": 0, \n      \"target\": {\n        \"key\": \"REMOVED IT BECAUSE OF POST LIMITATIONS\"\n      }\n    }\n  ], \n  \"extra\": [ 1, 108, 109, 63, 78, 182, 147, 31, 13, 63, 251, 116, 213, 150, 92, 35, 157, 53, 55, 182, 160, 24, 206, 159, 131, 96, 160, 20, 147, 162, 61, 159, 75, 2, 9, 1, 214, 209, 43, 119, 113, 218, 18, 237\n  ], \n  \"rct_signatures\": {\n    \"type\": 4, \n    \"txnFee\": 38530000, \n    \"ecdhInfo\": [ {\n        \"amount\": \"83feb6f4af3c4cf1\"\n      }, {\n        \"amount\": \"91518b4fed271728\"\n      }], \n    \"outPk\": [ \"REMOVED IT BECAUSE OF POST LIMITATIONS\", \"REMOVED IT BECAUSE OF POST LIMITATIONS\"]\n  }, \n  \"rctsig_prunable\": {\n    \"nbp\": 1, \n    \"bp\": [ {\n        \"A\": \"REMOVED IT BECAUSE OF POST LIMITATIONS\", \n        \"S\": \"REMOVED IT BECAUSE OF POST LIMITATIONS\", \n        \"T1\": \"REMOVED IT BECAUSE OF POST LIMITATIONS\", \n        \"T2\": \"REMOVED IT BECAUSE OF POST LIMITATIONS\", \n        \"taux\": \"REMOVED IT BECAUSE OF POST LIMITATIONS\", \n        \"mu\": \"REMOVED IT BECAUSE OF POST LIMITATIONS\", \n        \"L\": [ \"REMOVED IT BECAUSE OF POST LIMITATIONS\", \"REMOVED IT BECAUSE OF POST LIMITATIONS\", \"a667ef144e4f776a3fd4f823d3ade8f9ab98bb8b7163bc8af79e667f777b24b5\"\n        ], \n        \"R\": [ \"ee154acdfbdf5ab2fc617d081547fb3bbb3bf63ff51526fe51915a65cb5d38be\",  \"1751194a9e22f8a19744dda61c7b399383d20ce7297f6131d77b98d84d5f0889\"\n        ], \n        \"a\": \"662f242013d7d0228cf22376d62a7d90519c05f1c27d15426ea5049a4cf8a801\", \n        \"b\": \"223bb8b7f368b1e12b31395b702e48f6987281d20d2d8d177aa1c76d93d7ed07\", \n        \"t\": \"9b7ab768ad2d64ee840c92801190d8ff63e0c6b18e312854ffbdfb782836120c\"\n      }\n    ], \n    \"MGs\": [ {\n        \"ss\": [ [ \"4e584539e647667ea0302d333380347efaa1e0b838dcf6d88d4df7c7a35b2d03\", \"c0019ed466c82c3a1faf82a552d7e410360b4fd0462028ac6af371b6f45b080c\"], [ \"4eb169012f0d25f518d37202aaf510ca4b50367fa8f1c5bfa2ec212d22f09a06\", \"4986ee31787f36ba85c63815a4f893bf529da02e86e8a82a18537ea6a4eef600\"], [ \"2ae49225b63a6b8fd2bcb0114de24363c5407edeb8b87f5652d5030e7dead004\", \"90e482416b39cc4f9c8e167de280312e7326abd16fbafd9ef453ea926136d40d\"], [ \"ae8eb2cff90c4bfafd38e6bbec4781b5b522eb75985897480181c2c2b4fa3f03\", \"acd95ace580bc01ebba09c113c607d72a34a76982fc6c460df79b80e2b5af60c\"], [ \"d9678780d6a4df6004126351b241fbd0c557839c9613676095a792ffc9cecd04\", \"7ae5db4f77da9022a22c709ded46d12a3b23764d6f33991dcc7cf8442c3e2d08\"], [ \"cce8c876488f2e0388f00c7cc9d245b92b874d5e336c373d29f18ab4939ffa04\", \"bb11825cb13296e524a2f1c93a5c9f9c747a3c0caa7df3e8f3a0cfdd92da2d05\"], [ \"0e98c6e8ca5d4288560afcaf1e2da64378fbb0b2b33dee63b960b18fe654d100\", \"21151e9135bf98a42a2be553a4fe87c7ee672033d138b1fc3bde25ea7d641001\"], [ \"8056b853a0f8c42195f93910dc21769568bfdc7d1c27e7e2472b07388abead0c\", \"bdf38f57e0e0588ec2e59744ed50e6f7242f210069cf2440ec481743795f9d06\"], [ \"7b82e4cfbf5a8bb750f30954a66536cfe2cb104aad79efa1181030f273f1f909\", \"66bf95f614b01ae9a2d78596c9867ec0a9f6f91f77a62ad57af31c9c190d0d09\"], [ \"a82e64995039a34bd595d4d5e590534735be64fbda980fbe564fd590d45ced01\", \"6cb48349d7c0dfeaa2f85996b085e9ba0dd30274077e01ab95294e6a09ee810e\"], [ \"8563cf3c605235bb9cd299e5a9d76f931a95402a793c8e9cf8ec7e43e3a3820a\", \"f9e9078679736266aaa56691725a34c74d642e35e01a1dd868ca9a41b15e9700\"]], \n        \"cc\": \"d27fd2e412bed674a9b861bc7b0ce5148c0994fd7b115fa09f91ff1f9e44300f\"\n      }, {\n        \"ss\": [ [ \"badbaa022739ad376bf66c7ff7c7a5939dab9b5086e123820a6371364345e901\", \"f5e3a2c1157b6a9a4bc3474f73cdcedb19419c93913cba5a4efaebc9ee0f210d\"], [ \"201701983eeaf15a8ebc13032bcabca969ec3ed503026c0aebf927806d896d0c\", \"920d9905f43d3b6bef199899e25202e03ccd1ff38600629f2d44fe87e2ad6607\"], [ \"2fd0378a2b9f9fc63fdcd0c48cdd18e4060de808d1c91a5a335f01e211493407\", \"a090f4901b919896b3a27ca32c340c0e4342e4d16e677f8ebe32fc4d175aca0d\"], [ \"88b6fd69f369b51b450aeb372b31eb4efe8bce9f9659138ad29510b0e13c2506\", \"7bd75e8993da85a1608643a22d015ea83c5d936c7d8d928017e65e7dc5f97607\"], [ \"adb21a130e00f36563eb359617388e6008b28ec88665cd4daac40277b1463d04\", \"4f8c49f89feaed84eee3ac809d4351bdf4dd93911cc35a40289d18ccd3feb802\"], [ \"5e0f5d502460d979f1b9243ee4d0bef18caaa2955c46eafa3982a986a50a470a\", \"6e75a452e2e9990ff58805955a37399efb85c5134bad6b39640f405ce3e5af0f\"], [ \"f7afef22ce1a4e645e6dfe1a468c1f173286c9f6feacef1bbefe1cb982bfe502\", \"315fc0a31f3ec939f877dedc2943182338dc78dc5830f545e545da8041cbe30f\"], [ \"0d37190d3049bef5a07f3bc3f2d31c22ca34b14f6a0def500ef6c3c75501220f\", \"2a4ae97bf8a0415da1cfd2a25dab8e9f978245ad724061484f903f64ce751d0d\"], [ \"4b0b43068b11fc85d85c64d9de73f630e0d183744f64f9778d638bb344930104\", \"00ec7f91ea6c003e69a474c38339d43dc42455fad8219134a6610ee1c5e64702\"], [ \"e477cbf3c5d0bca539d57cc2606c96c1cffd10f919e5580949f9361f7c1c2c0e\", \"d5e5f0c65ebeca71466d67f7f93c860c5919bd73cab0c7245428f1895c023d04\"], [ \"9723ebdf6e50253688ce52789230784a50289d92dbbced903f28f8bbab66250d\", \"8ebb3da0b5311b5650f72881b5856a70324598174713cb7fc1a508db46944a09\"]], \n        \"cc\": \"d10590aa918d70524c208734b46c58d03f62371c8db3fe4f2561feac42625d00\"\n      }], \n    \"pseudoOuts\": [ \"0146403b8a65a08bf717dbc5c584c1d8d3805466ac04f26cea95727f8de6d9ba\", \"986cde3b94bd0f22624ab56ac711c13cca5935078d2d97bcb2a62692a7796ddc\"]\n  }\n}",
"block_height": 1956015,
"block_timestamp": 1572436020,
"double_spend_seen": false,
"in_pool": false,
"output_indices": [12976615,12976616],
"prunable_as_hex": "",
"prunable_hash": "20f44f2e37d3cfda4a7a9cde89054a78c58e2ace411f0bbb89baf5be5fcb77ea",
"pruned_as_hex": "",
"tx_hash": "184d4311e757f70bc4a66878d5901247cf6ced4e743924535d917ae55fc57f8d"
 }],
"txs_as_hex": ["02000202000bc8f1f10497f859c8943d909d05da97088b8c01c315b80de91aef01ee0264222dc3ca132cd4bbba26fa89ac1fee71b1f7812be8ee39c6d05b8b2bc25fc202000b90dfb2058db308b779d2bd4cb28406d58302ec9d05c5239b4d8d4c993b4889fdf95d1b1a20598a62cea7dcfcbc7f427e28227ff11cb62fc9ddffa08c88020002e58ac5597c76995e969a3681e7aeaf960ed669f7da602fe862052dbd845ec12e00023c379e3828d80b070032d185ca89d44d8c6c3d61da13e4c7e59b855a48dbaa3a2c016c6d3f4eb6931f0d3ffb74d5965c239d3537b6a018ce9f8360a01493a23d9f4b020901d6d12b7771da12ed04d0d7af1283feb6f4af3c4cf191518b4fed271728abd6db3824bfc3a907a87672cd7163285d7a1d54b9505128edfcf29304952d74799920cd42c33dd35217f8821a0bafe79655a17fdcdc22df7c0beedbb26463cd01c106bd65dd94eedcfdc9c656ad95913f0b82db3fc91fa02c149fd3c6fc81d61c4432845d27bc075ba7ac2bf6feeb405709996a027e2ed33d6f395fea5ffc9ed1d7a497742c6cd3da9645bef4e96c2c567528a2b154a58ed77778faac86e756134ad435b3a2736e8bec176d56a10fbbe7a8095ed1ac59c13b7464a50aa475555dd6721a158e079d31b3acb5ad2d37fbd42b7d8808bf6bfcf1b8be5664b78973092eef2a2439b3a6c1755d485ccc5ca0cfdff5be1acb419e2b92066bda3919e40b07d3bf9d60ed13cd85e497e1ba847bbf0c1ebad703273058830d1116e0d5eae17c7767aad8c0dec42ac03986a21ea32b109048b84b8d92fcfebdc85e8ad78adbcd0453fe8182411e5abba283d4f5a733e690151b5b2e0baf47d98679816990994fe3e08866bb5a25061d763bc24e756804021746f81fc053a1dca0b0311da9e0c9a14bb7c22043f8b4a42cb15009013dcb9c8086f5c0babac8ba4ea9da5488e2d740ae6fff2d13d797e49741269556aa7bdea8521d675b92a53a844e428e26fb65a667ef144e4f776a3fd4f823d3ade8f9ab98bb8b7163bc8af79e667f777b24b507ee154acdfbdf5ab2fc617d081547fb3bbb3bf63ff51526fe51915a65cb5d38be5f2ca197ccb7ca8dcdf10c066f9f6877ec28a5f80239b87ad1f9fed89b33d30584fa8082f9d4ca505762076b81ccf16299b0c61556fffc86369e630eb612bb324b714df5f14fb63d99b48351ed8d9ffd278ad58b6a1bfed4141d9564a37d3064006103d7448aa26e9772e658e9c1e475328920fcc27a079616d3a912e0f0d2d0d2b268884c85c439b9cb2c7b7916d185c76499c2709e59e28b6893f95ae8737f1751194a9e22f8a19744dda61c7b399383d20ce7297f6131d77b98d84d5f0889662f242013d7d0228cf22376d62a7d90519c05f1c27d15426ea5049a4cf8a801223bb8b7f368b1e12b31395b702e48f6987281d20d2d8d177aa1c76d93d7ed079b7ab768ad2d64ee840c92801190d8ff63e0c6b18e312854ffbdfb782836120c4e584539e647667ea0302d333380347efaa1e0b838dcf6d88d4df7c7a35b2d03c0019ed466c82c3a1faf82a552d7e410360b4fd0462028ac6af371b6f45b080c4eb169012f0d25f518d37202aaf510ca4b50367fa8f1c5bfa2ec212d22f09a064986ee31787f36ba85c63815a4f893bf529da02e86e8a82a18537ea6a4eef6002ae49225b63a6b8fd2bcb0114de24363c5407edeb8b87f5652d5030e7dead00490e482416b39cc4f9c8e167de280312e7326abd16fbafd9ef453ea926136d40dae8eb2cff90c4bfafd38e6bbec4781b5b522eb75985897480181c2c2b4fa3f03acd95ace580bc01ebba09c113c607d72a34a76982fc6c460df79b80e2b5af60cd9678780d6a4df6004126351b241fbd0c557839c9613676095a792ffc9cecd047ae5db4f77da9022a22c709ded46d12a3b23764d6f33991dcc7cf8442c3e2d08cce8c876488f2e0388f00c7cc9d245b92b874d5e336c373d29f18ab4939ffa04bb11825cb13296e524a2f1c93a5c9f9c747a3c0caa7df3e8f3a0cfdd92da2d050e98c6e8ca5d4288560afcaf1e2da64378fbb0b2b33dee63b960b18fe654d10021151e9135bf98a42a2be553a4fe87c7ee672033d138b1fc3bde25ea7d6410018056b853a0f8c42195f93910dc21769568bfdc7d1c27e7e2472b07388abead0cbdf38f57e0e0588ec2e59744ed50e6f7242f210069cf2440ec481743795f9d067b82e4cfbf5a8bb750f30954a66536cfe2cb104aad79efa1181030f273f1f90966bf95f614b01ae9a2d78596c9867ec0a9f6f91f77a62ad57af31c9c190d0d09a82e64995039a34bd595d4d5e590534735be64fbda980fbe564fd590d45ced016cb48349d7c0dfeaa2f85996b085e9ba0dd30274077e01ab95294e6a09ee810e8563cf3c605235bb9cd299e5a9d76f931a95402a793c8e9cf8ec7e43e3a3820af9e9078679736266aaa56691725a34c74d642e35e01a1dd868ca9a41b15e9700d27fd2e412bed674a9b861bc7b0ce5148c0994fd7b115fa09f91ff1f9e44300fbadbaa022739ad376bf66c7ff7c7a5939dab9b5086e123820a6371364345e901f5e3a2c1157b6a9a4bc3474f73cdcedb19419c93913cba5a4efaebc9ee0f210d201701983eeaf15a8ebc13032bcabca969ec3ed503026c0aebf927806d896d0c920d9905f43d3b6bef199899e25202e03ccd1ff38600629f2d44fe87e2ad66072fd0378a2b9f9fc63fdcd0c48cdd18e4060de808d1c91a5a335f01e211493407a090f4901b919896b3a27ca32c340c0e4342e4d16e677f8ebe32fc4d175aca0d88b6fd69f369b51b450aeb372b31eb4efe8bce9f9659138ad29510b0e13c25067bd75e8993da85a1608643a22d015ea83c5d936c7d8d928017e65e7dc5f97607adb21a130e00f36563eb359617388e6008b28ec88665cd4daac40277b1463d044f8c49f89feaed84eee3ac809d4351bdf4dd93911cc35a40289d18ccd3feb8025e0f5d502460d979f1b9243ee4d0bef18caaa2955c46eafa3982a986a50a470a6e75a452e2e9990ff58805955a37399efb85c5134bad6b39640f405ce3e5af0ff7afef22ce1a4e645e6dfe1a468c1f173286c9f6feacef1bbefe1cb982bfe502315fc0a31f3ec939f877dedc2943182338dc78dc5830f545e545da8041cbe30f0d37190d3049bef5a07f3bc3f2d31c22ca34b14f6a0def500ef6c3c75501220f2a4ae97bf8a0415da1cfd2a25dab8e9f978245ad724061484f903f64ce751d0d4b0b43068b11fc85d85c64d9de73f630e0d183744f64f9778d638bb34493010400ec7f91ea6c003e69a474c38339d43dc42455fad8219134a6610ee1c5e64702e477cbf3c5d0bca539d57cc2606c96c1cffd10f919e5580949f9361f7c1c2c0ed5e5f0c65ebeca71466d67f7f93c860c5919bd73cab0c7245428f1895c023d049723ebdf6e50253688ce52789230784a50289d92dbbced903f28f8bbab66250d8ebb3da0b5311b5650f72881b5856a70324598174713cb7fc1a508db46944a09d10590aa918d70524c208734b46c58d03f62371c8db3fe4f2561feac42625d000146403b8a65a08bf717dbc5c584c1d8d3805466ac04f26cea95727f8de6d9ba986cde3b94bd0f22624ab56ac711c13cca5935078d2d97bcb2a62692a7796ddc"],
 "txs_as_json": ["{\n  \"version\": 2, \n  \"unlock_time\": 0, \n  \"vin\": [ {\n      \"key\": {\n        \"amount\": 0, \n        \"key_offsets\": [ 10254536, 1473559, 1002056, 85648, 134106, 17931, 2755, 1720, 3433, 239, 366\n        ], \n        \"k_image\": \"64222dc3ca132cd4bbba26fa89ac1fee71b1f7812be8ee39c6d05b8b2bc25fc2\"\n      }\n    }, {\n      \"key\": {\n        \"amount\": 0, \n        \"key_offsets\": [ 11317136, 137613, 15543, 1253074, 98866, 33237, 85740, 4549, 9883, 9741, 7577\n        ], \n        \"k_image\": \"4889fdf95d1b1a20598a62cea7dcfcbc7f427e28227ff11cb62fc9ddffa08c88\"\n      }\n    }\n  ], \n  \"vout\": [ {\n      \"amount\": 0, \n      \"target\": {\n        \"key\": \"e58ac5597c76995e969a3681e7aeaf960ed669f7da602fe862052dbd845ec12e\"\n      }\n    }, {\n      \"amount\": 0, \n      \"target\": {\n        \"key\": \"3c379e3828d80b070032d185ca89d44d8c6c3d61da13e4c7e59b855a48dbaa3a\"\n      }\n    }\n  ], \n  \"extra\": [ 1, 108, 109, 63, 78, 182, 147, 31, 13, 63, 251, 116, 213, 150, 92, 35, 157, 53, 55, 182, 160, 24, 206, 159, 131, 96, 160, 20, 147, 162, 61, 159, 75, 2, 9, 1, 214, 209, 43, 119, 113, 218, 18, 237\n  ], \n  \"rct_signatures\": {\n    \"type\": 4, \n    \"txnFee\": 38530000, \n    \"ecdhInfo\": [ {\n        \"amount\": \"83feb6f4af3c4cf1\"\n      }, {\n        \"amount\": \"91518b4fed271728\"\n      }], \n    \"outPk\": [ \"abd6db3824bfc3a907a87672cd7163285d7a1d54b9505128edfcf29304952d74\", \"799920cd42c33dd35217f8821a0bafe79655a17fdcdc22df7c0beedbb26463cd\"]\n  }, \n  \"rctsig_prunable\": {\n    \"nbp\": 1, \n    \"bp\": [ {\n        \"A\": \"c106bd65dd94eedcfdc9c656ad95913f0b82db3fc91fa02c149fd3c6fc81d61c\", \n        \"S\": \"4432845d27bc075ba7ac2bf6feeb405709996a027e2ed33d6f395fea5ffc9ed1\", \n        \"T1\": \"d7a497742c6cd3da9645bef4e96c2c567528a2b154a58ed77778faac86e75613\", \n        \"T2\": \"4ad435b3a2736e8bec176d56a10fbbe7a8095ed1ac59c13b7464a50aa475555d\", \n        \"taux\": \"d6721a158e079d31b3acb5ad2d37fbd42b7d8808bf6bfcf1b8be5664b7897309\", \n        \"mu\": \"2eef2a2439b3a6c1755d485ccc5ca0cfdff5be1acb419e2b92066bda3919e40b\", \n        \"L\": [ \"d3bf9d60ed13cd85e497e1ba847bbf0c1ebad703273058830d1116e0d5eae17c\", \"7767aad8c0dec42ac03986a21ea32b109048b84b8d92fcfebdc85e8ad78adbcd\", \"0453fe8182411e5abba283d4f5a733e690151b5b2e0baf47d98679816990994f\", \"e3e08866bb5a25061d763bc24e756804021746f81fc053a1dca0b0311da9e0c9\", \"a14bb7c22043f8b4a42cb15009013dcb9c8086f5c0babac8ba4ea9da5488e2d7\", \"40ae6fff2d13d797e49741269556aa7bdea8521d675b92a53a844e428e26fb65\", \"a667ef144e4f776a3fd4f823d3ade8f9ab98bb8b7163bc8af79e667f777b24b5\"\n        ], \n        \"R\": [ \"ee154acdfbdf5ab2fc617d081547fb3bbb3bf63ff51526fe51915a65cb5d38be\", \"5f2ca197ccb7ca8dcdf10c066f9f6877ec28a5f80239b87ad1f9fed89b33d305\", \"84fa8082f9d4ca505762076b81ccf16299b0c61556fffc86369e630eb612bb32\", \"4b714df5f14fb63d99b48351ed8d9ffd278ad58b6a1bfed4141d9564a37d3064\", \"006103d7448aa26e9772e658e9c1e475328920fcc27a079616d3a912e0f0d2d0\", \"d2b268884c85c439b9cb2c7b7916d185c76499c2709e59e28b6893f95ae8737f\", \"1751194a9e22f8a19744dda61c7b399383d20ce7297f6131d77b98d84d5f0889\"\n        ], \n        \"a\": \"662f242013d7d0228cf22376d62a7d90519c05f1c27d15426ea5049a4cf8a801\", \n        \"b\": \"223bb8b7f368b1e12b31395b702e48f6987281d20d2d8d177aa1c76d93d7ed07\", \n        \"t\": \"9b7ab768ad2d64ee840c92801190d8ff63e0c6b18e312854ffbdfb782836120c\"\n      }\n    ], \n    \"MGs\": [ {\n        \"ss\": [ [ \"4e584539e647667ea0302d333380347efaa1e0b838dcf6d88d4df7c7a35b2d03\", \"c0019ed466c82c3a1faf82a552d7e410360b4fd0462028ac6af371b6f45b080c\"], [ \"4eb169012f0d25f518d37202aaf510ca4b50367fa8f1c5bfa2ec212d22f09a06\", \"4986ee31787f36ba85c63815a4f893bf529da02e86e8a82a18537ea6a4eef600\"], [ \"2ae49225b63a6b8fd2bcb0114de24363c5407edeb8b87f5652d5030e7dead004\", \"90e482416b39cc4f9c8e167de280312e7326abd16fbafd9ef453ea926136d40d\"], [ \"ae8eb2cff90c4bfafd38e6bbec4781b5b522eb75985897480181c2c2b4fa3f03\", \"acd95ace580bc01ebba09c113c607d72a34a76982fc6c460df79b80e2b5af60c\"], [ \"d9678780d6a4df6004126351b241fbd0c557839c9613676095a792ffc9cecd04\", \"7ae5db4f77da9022a22c709ded46d12a3b23764d6f33991dcc7cf8442c3e2d08\"], [ \"cce8c876488f2e0388f00c7cc9d245b92b874d5e336c373d29f18ab4939ffa04\", \"bb11825cb13296e524a2f1c93a5c9f9c747a3c0caa7df3e8f3a0cfdd92da2d05\"], [ \"0e98c6e8ca5d4288560afcaf1e2da64378fbb0b2b33dee63b960b18fe654d100\", \"21151e9135bf98a42a2be553a4fe87c7ee672033d138b1fc3bde25ea7d641001\"], [ \"8056b853a0f8c42195f93910dc21769568bfdc7d1c27e7e2472b07388abead0c\", \"bdf38f57e0e0588ec2e59744ed50e6f7242f210069cf2440ec481743795f9d06\"], [ \"7b82e4cfbf5a8bb750f30954a66536cfe2cb104aad79efa1181030f273f1f909\", \"66bf95f614b01ae9a2d78596c9867ec0a9f6f91f77a62ad57af31c9c190d0d09\"], [ \"a82e64995039a34bd595d4d5e590534735be64fbda980fbe564fd590d45ced01\", \"6cb48349d7c0dfeaa2f85996b085e9ba0dd30274077e01ab95294e6a09ee810e\"], [ \"8563cf3c605235bb9cd299e5a9d76f931a95402a793c8e9cf8ec7e43e3a3820a\", \"f9e9078679736266aaa56691725a34c74d642e35e01a1dd868ca9a41b15e9700\"]], \n        \"cc\": \"d27fd2e412bed674a9b861bc7b0ce5148c0994fd7b115fa09f91ff1f9e44300f\"\n      }, {\n        \"ss\": [ [ \"badbaa022739ad376bf66c7ff7c7a5939dab9b5086e123820a6371364345e901\", \"f5e3a2c1157b6a9a4bc3474f73cdcedb19419c93913cba5a4efaebc9ee0f210d\"], [ \"201701983eeaf15a8ebc13032bcabca969ec3ed503026c0aebf927806d896d0c\", \"920d9905f43d3b6bef199899e25202e03ccd1ff38600629f2d44fe87e2ad6607\"], [ \"2fd0378a2b9f9fc63fdcd0c48cdd18e4060de808d1c91a5a335f01e211493407\", \"a090f4901b919896b3a27ca32c340c0e4342e4d16e677f8ebe32fc4d175aca0d\"], [ \"88b6fd69f369b51b450aeb372b31eb4efe8bce9f9659138ad29510b0e13c2506\", \"7bd75e8993da85a1608643a22d015ea83c5d936c7d8d928017e65e7dc5f97607\"], [ \"adb21a130e00f36563eb359617388e6008b28ec88665cd4daac40277b1463d04\", \"4f8c49f89feaed84eee3ac809d4351bdf4dd93911cc35a40289d18ccd3feb802\"], [ \"5e0f5d502460d979f1b9243ee4d0bef18caaa2955c46eafa3982a986a50a470a\", \"6e75a452e2e9990ff58805955a37399efb85c5134bad6b39640f405ce3e5af0f\"], [ \"f7afef22ce1a4e645e6dfe1a468c1f173286c9f6feacef1bbefe1cb982bfe502\", \"315fc0a31f3ec939f877dedc2943182338dc78dc5830f545e545da8041cbe30f\"], [ \"0d37190d3049bef5a07f3bc3f2d31c22ca34b14f6a0def500ef6c3c75501220f\", \"2a4ae97bf8a0415da1cfd2a25dab8e9f978245ad724061484f903f64ce751d0d\"], [ \"4b0b43068b11fc85d85c64d9de73f630e0d183744f64f9778d638bb344930104\", \"00ec7f91ea6c003e69a474c38339d43dc42455fad8219134a6610ee1c5e64702\"], [ \"e477cbf3c5d0bca539d57cc2606c96c1cffd10f919e5580949f9361f7c1c2c0e\", \"d5e5f0c65ebeca71466d67f7f93c860c5919bd73cab0c7245428f1895c023d04\"], [ \"9723ebdf6e50253688ce52789230784a50289d92dbbced903f28f8bbab66250d\", \"8ebb3da0b5311b5650f72881b5856a70324598174713cb7fc1a508db46944a09\"]], \n        \"cc\": \"d10590aa918d70524c208734b46c58d03f62371c8db3fe4f2561feac42625d00\"\n      }], \n    \"pseudoOuts\": [ \"0146403b8a65a08bf717dbc5c584c1d8d3805466ac04f26cea95727f8de6d9ba\", \"986cde3b94bd0f22624ab56ac711c13cca5935078d2d97bcb2a62692a7796ddc\"]\n  }\n}"],
"untrusted": false
}

Я толькохочу "лишнюю" часть от этого. Я делаю это правильно?

1 Ответ

1 голос
/ 07 ноября 2019

Если у вас неправильный, сломанный, отсутствующий json .. По моему опыту есть 2 способа:

  • найти необходимую часть из строки и попытаться проанализировать только эту часть.
  • напишите свой собственный Json Resolver.

в своем примере вы говорите, что я только касаюсь дополнительной частии т. д. Я выбираю простой способ по первому варианту, чтобы вы могли найти дополнительные данные и проанализировать их. Список int и использовать их. Так что не волнуйтесь, огромный неправильный блок.

            int lastindex = 0;
            while (true)  
            {
                var indexofextra = data.IndexOf("\"extra", lastindex + 1);
                if (indexofextra == -1)
                    break;


                lastindex = indexofextra;

                var indexOfStartExtra = data.IndexOf("[", lastindex + 1);
                if (indexOfStartExtra == -1)
                    break;

                var indexOfEndExtra = data.IndexOf("]", lastindex + 1);
                if (indexOfEndExtra == -1)
                    break;

                var dataOfExtra = data.Substring(indexOfStartExtra, (indexOfEndExtra - indexOfStartExtra) +1);
                dataOfExtra = dataOfExtra.Replace("\n", "");

                var extraData = JsonConvert.DeserializeObject<List<int>>(dataOfExtra);
            }
...