Exemplo n.º 1
0
        public static Trading.OrderLive ParseOrderLive(string text)
        {
            System.Text.Json.JsonParser parser = new System.Text.Json.JsonParser();
            OrderLive order = parser.Parse <OrderLive>(text);

            return(order);
        }
Exemplo n.º 2
0
        public static void FastJsonParserTest(string json)
        {
            jp.Parse <List <Monitor> >(json);
            jp.Parse <List <Monitor> >(json);
            jp.Parse <List <Monitor> >(json);

            Stopwatch sw = new Stopwatch();

            sw.Start();
            for (int i = 0; i < 25000; i++)
            {
                var monitors = jp.Parse <List <Monitor> >(json);
            }
            sw.Stop();

            Debug.WriteLine("FastJson read " + sw.ElapsedMilliseconds + "ms");
        }
Exemplo n.º 3
0
        public static void DoTests()
        {
            //Monitors2 is being loaded the same way, but will serialize differently since it is Monitor2
            //It has the field aliases

            var monitors = JsonConvert.DeserializeObject <List <Monitor> >(EmbeddedJson.MonitorRecords);

            //Deserializing with this parser since it ignores the column names.
            var monitors2 = jp.Parse <List <Monitor2> >(EmbeddedJson.MonitorRecords);

            ServiceStackTest(monitors);
            ServiceStackMiniTest(monitors2);
            NewtonsoftTest(monitors);
            NewtonsoftGenericTest();
            NewtonsoftTestMini(monitors2);
            DataContractSerializerTest(monitors);
        }
Exemplo n.º 4
0
 public static IDictionary <string, PoloniexAPI.WalletTools.IBalance> ParseBalances(string text)
 {
     try {
         System.Text.Json.JsonParser      parser = new System.Text.Json.JsonParser();
         KeyValuePair <string, Balance>[] data   = parser.Parse <Dictionary <string, Balance> >(text).ToArray();
         IDictionary <string, PoloniexAPI.WalletTools.IBalance> returnData = new Dictionary <string, PoloniexAPI.WalletTools.IBalance>();
         for (int i = 0; i < data.Length; i++)
         {
             returnData.Add(new KeyValuePair <string, PoloniexAPI.WalletTools.IBalance>(data[i].Key, (PoloniexAPI.WalletTools.Balance)data[i].Value));
         }
         return(returnData);
     }
     catch (Exception e) {
         Console.WriteLine("JSON Parser, line 22");
         Console.WriteLine(e.Message);
         return(null);
     }
 }
Exemplo n.º 5
0
 public static JsonObject Parse(ReadOnlySpan<byte> utf8Json, BufferPool pool = null)
 {
     var parser = new JsonParser();
     var result = parser.Parse(utf8Json, pool);
     return result;
 }
Exemplo n.º 6
0
 public static JsonObject Parse(ReadOnlySpan<byte> utf8Json)
 {
     var parser = new JsonParser();
     var result = parser.Parse(utf8Json);
     return result;
 }
Exemplo n.º 7
0
 uint? ReadCountUsingNonAllocatingDom(ReadOnlySpan<byte> json)
 {
     var parser = new JsonParser(json.CreateArray(), json.Length); // TODO: eliminate allocation
     JsonParseObject jsonObject = parser.Parse();
     uint count = (uint)jsonObject["Count"];
     return count;
 }