Ejemplo n.º 1
0
        public static TwitterBoundingBox Parse(JsonObject obj)
        {
            // Check whether "obj" is NULL
            if (obj == null)
            {
                return(null);
            }

            // Get the array
            JsonArray coordinates = obj.GetArray("coordinates");

            // Initialize the bounding box
            TwitterBoundingBox boundingBox = new TwitterBoundingBox {
                Type        = obj.GetString("type"),
                Coordinates = new TwitterCoordinates[coordinates.Length][]
            };

            // Parse the coordinates
            for (int i = 0; i < coordinates.Length; i++)
            {
                boundingBox.Coordinates[i] = TwitterCoordinates.ParseMultiple(coordinates.GetArray(i));
            }

            // Return the building box
            return(boundingBox);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 读取本地Emoji词库
        /// </summary>
        /// <returns>返回词库List</returns>
        public static async Task <List <MyEmoji> > ReadLocalEmoji()
        {
            GlobalTool.EmojiJson = string.Empty;
            try
            {
                StorageFolder folder = ApplicationData.Current.LocalFolder;
                StorageFile   file   = await folder.GetFileAsync(EmojiFileName);

                GlobalTool.EmojiJson = await FileIO.ReadTextAsync(file);

                JsonArray      array = JsonArray.Parse(GlobalTool.EmojiJson);
                List <MyEmoji> list  = new List <MyEmoji>();
                foreach (IJsonValue jsonValue in array.GetArray())
                {
                    if (jsonValue.ValueType == JsonValueType.Object)
                    {
                        list.Add(new MyEmoji(jsonValue.GetObject()));
                    }
                }
                return(list);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                return(null);
            }
        }
Ejemplo n.º 3
0
        /**
         *
         */
        private void FillChart(JsonArray j)
        {
            SeriesCollection.Clear();

            List <double> d = new List <double>();

            foreach (var item in j.GetArray())
            {
                var obj = item.GetObject();
                d.Add(Double.Parse(obj["high"].GetString()));
            }

            ChartValues <double> v = new ChartValues <double>();

            foreach (double i in d)
            {
                v.Add(i);
            }

            SeriesCollection.Add(
                new LineSeries
            {
                Title  = "2018",
                Values = v
            }
                );

            DataContext = this;
        }
 public static TwitterCoordinates[] ParseMultiple(JsonArray array) {
     if (array == null) return new TwitterCoordinates[0];
     TwitterCoordinates[] temp = new TwitterCoordinates[array.Length];
     for (int i = 0; i < array.Length; i++) {
         temp[i] = Parse(array.GetArray(i));
     }
     return temp;
 }
Ejemplo n.º 5
0
 public static AnalyticsDataRow[] ParseMultiDimensionArray(JsonArray array)
 {
     AnalyticsDataRow[] rows = new AnalyticsDataRow[array.Length];
     for (int i = 0; i < array.Length; i++)
     {
         rows[i] = new AnalyticsDataRow {
             Index = i,
             Cells = array.GetArray(i).Cast <string>()
         };
     }
     return(rows);
 }
Ejemplo n.º 6
0
 public static TwitterCoordinates[] ParseMultiple(JsonArray array)
 {
     if (array == null)
     {
         return(new TwitterCoordinates[0]);
     }
     TwitterCoordinates[] temp = new TwitterCoordinates[array.Length];
     for (int i = 0; i < array.Length; i++)
     {
         temp[i] = Parse(array.GetArray(i));
     }
     return(temp);
 }
        /// <summary>
        /// Gets an instance of <var>AnalyticsRealtimeDataResponse</var> from the specified
        /// <var>JsonObject</var>.
        /// </summary>
        /// <param name="obj">The instance of <var>JsonObject</var> to parse.</param>
        public static AnalyticsRealtimeDataResponse Parse(JsonObject obj)
        {
            // Check whether "obj" is NULL
            if (obj == null)
            {
                return(null);
            }

            // Check for any API errors
            if (obj.HasValue("error"))
            {
                JsonObject error = obj.GetObject("error");
                throw new GoogleApiException(error.GetInt("code"), error.GetString("message"));
            }

            // Initialize the response object
            AnalyticsRealtimeDataResponse response = new AnalyticsRealtimeDataResponse {
                JsonObject    = obj,
                Query         = obj.GetObject("query", AnalyticsRealtimeDataQuery.Parse),
                TotalResults  = obj.GetInt("totalResults"),
                ColumnHeaders = obj.GetArray("columnHeaders", AnalyticsDataColumnHeader.Parse)
            };

            // Get total result values
            foreach (KeyValuePair <string, object> pair in obj.GetObject("totalsForAllResults").Dictionary)
            {
                response._totalsForAllResults.Add(pair.Key, pair.Value.ToString());
            }

            // Parse the rows
            JsonArray rows = obj.GetArray("rows");

            if (rows == null)
            {
                response.Rows = new AnalyticsDataRow[0];
            }
            else
            {
                response.Rows = new AnalyticsDataRow[rows.Length];
                for (int i = 0; i < rows.Length; i++)
                {
                    response.Rows[i] = new AnalyticsDataRow {
                        Index = i,
                        Cells = rows.GetArray(i).Cast <string>()
                    };
                }
            }


            return(response);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Gets an instance of <var>AnalyticsDataResponse</var> from the specified
        /// <var>JsonObject</var>.
        /// </summary>
        /// <param name="obj">The instance of <var>JsonObject</var> to parse.</param>
        public static AnalyticsDataResponse Parse(JsonObject obj)
        {
            // Check whether "obj" is NULL
            if (obj == null)
            {
                return(null);
            }

            // Check for any API errors
            if (obj.HasValue("error"))
            {
                JsonObject error = obj.GetObject("error");
                throw new GoogleApiException(error.GetInt("code"), error.GetString("message"));
            }

            // Initialize the response object
            AnalyticsDataResponse response = new AnalyticsDataResponse {
                Query         = obj.GetObject("query", AnalyticsDataQuery.Parse),
                ColumnHeaders = obj.GetArray("columnHeaders", AnalyticsDataColumnHeader.Parse)
            };

            // Parse the rows
            JsonArray rows = obj.GetArray("rows");

            if (rows == null)
            {
                response.Rows = new AnalyticsDataRow[0];
            }
            else
            {
                response.Rows = new AnalyticsDataRow[rows.Length];
                for (int i = 0; i < rows.Length; i++)
                {
                    response.Rows[i] = new AnalyticsDataRow {
                        Index = i,
                        Cells = rows.GetArray(i).Cast <string>()
                    };
                }
            }

            return(response);
        }
Ejemplo n.º 9
0
        internal static AnalyticsDataRow[] Parse(AnalyticsDataColumnHeader[] columnHeaders, JsonArray array)
        {
            // If the query returns no rows, the array will be NULL
            if (array == null)
            {
                return(new AnalyticsDataRow[0]);
            }

            // Initialize the array of rows with a fixed length based on the input array
            AnalyticsDataRow[] rows = new AnalyticsDataRow[array.Length];

            // Iterate through each row
            for (int i = 0; i < array.Length; i++)
            {
                // Get the array of the row
                JsonArray row = array.GetArray(i);

                rows[i] = new AnalyticsDataRow {
                    Index = i
                };

                // Iterate through each cell
                for (int j = 0; j < row.Length; j++)
                {
                    // Get the column header
                    AnalyticsDataColumnHeader column = columnHeaders[j];

                    // Add the key and value to the dictionary
                    rows[i]._cells.Add(column.Name, new AnalyticsDataCell {
                        Row    = rows[i],
                        Index  = j,
                        Column = column,
                        Value  = row.GetString(j)
                    });

                    // Set the array
                    rows[i].Cells = rows[i]._cells.Values.ToArray();
                }
            }

            return(rows);
        }