ReadValue() 공개 메소드

public ReadValue ( ) : object
리턴 object
예제 #1
0
        public static void Run()
        {
            string jsonText = "{ xyz: 123, items: [ 10, 100, 1000 ], numbers: [ 0.123, .456 ], bools: [ true, false ], text: [ \"hello\", 'world\n!' ] }";

            JsonReader jsonReader = new JsonReader(jsonText);
            dynamic jsonObject = jsonReader.ReadValue();
            dynamic items = jsonObject.items;

            items[2] = 1001;

            dynamic bar = new JsonObject();
            bar.name = "c#";

            jsonObject.bar = bar;

            JsonWriter writer = new JsonWriter();
            writer.WriteValue((object)jsonObject);

            string newJsonText = writer.Json;

            Console.WriteLine(newJsonText);
        }
예제 #2
0
        public static void Run()
        {
            string jsonText = "{ xyz: 123, items: [ 10, 100, 1000 ] }";

            JsonReader jsonReader = new JsonReader(jsonText);
            dynamic jsonObject = jsonReader.ReadValue();
            dynamic items = jsonObject.items;

            items.Item(2, 1001);

            dynamic bar = new JsonObject();
            bar.name = "c#";

            jsonObject.bar = bar;

            JsonWriter writer = new JsonWriter();
            writer.WriteValue((object)jsonObject);

            string newJsonText = writer.Json;

            Console.WriteLine(newJsonText);
        }
예제 #3
0
        private object ProcessResponse(Stream responseStream)
        {
            dynamic result = null;

            try {
                string responseText = (new StreamReader(responseStream)).ReadToEnd();
                if (_service == RestService.Json) {
                    JsonReader jsonReader = new JsonReader(responseText);
                    result = jsonReader.ReadValue();
                }
                else {
                    responseText = StripXmlnsRegex.Replace(responseText, String.Empty);
                    XDocument xmlDocument = XDocument.Parse(responseText);

                    result = new XmlNode(xmlDocument.Root);
                }
            }
            catch {
            }

            return result;
        }