Example #1
0
    public void SetFunction(string url)
    {
        strResponse = RequestForm.HttpGetByWebRequ(url);

        var myJson = JsonConvert.DeserializeObject <Request_for_OKTMO_units_2>(strResponse);

        Parse(myJson);
    }
Example #2
0
    public void SetFunction(string url)
    {
        strResponse = RequestForm.HttpGetByWebRequ(url);

        str = strResponse;

        //str = str.Replace("\"name\":\"Полное наименование тестового офиса\"", "");

        lines = str.Split(new char[] { ',' });

        foreach (string s in lines)
        {
            if (s.Contains("\"id\":") || s.Contains("\"description\":"))
            {
                IDAndName.Add(s);
            }
        }

        for (int i = 0; i < IDAndName.Count; i++)
        {
            if ((IDAndName[i].Contains("\"name\":\"Полное наименование тестового офиса\"")) || (IDAndName[i].Contains("Льготные категории граждан")) ||
                (IDAndName[i].Contains("\"unit\"")) || (IDAndName[i].Contains("\"faceTypes\"")))
            {
                IDAndName[i] = "";
            }

            IDAndName[i] = IDAndName[i].Replace("\"id\":", "");
            IDAndName[i] = IDAndName[i].Replace("\"description\":", "");
            IDAndName[i] = IDAndName[i].Replace("\"children\":[{", "");
            IDAndName[i] = IDAndName[i].Replace("\"childrenGroups\":[{", "");
            IDAndName[i] = IDAndName[i].Replace("{", "");
            IDAndName[i] = IDAndName[i].Replace("[", "");
            IDAndName[i] = IDAndName[i].Replace("\"", "");
            IDAndName[i] = IDAndName[i].Replace("null", "");
            //IDAndName[i] = IDAndName[i].Replace(", "");
        }

        IDAndName[0] = "";


        List <string> newList = new List <string>();

        foreach (string s in IDAndName)
        {
            if (s != "")
            {
                newList.Add(s);
            }
        }

        IDAndName = newList;



        //var myJson = JsonConvert.DeserializeObject<Unitidrequest_3>(strResponse);

        //Parse(myJson);
    }