Пример #1
0
        /// <summary>
        /// Return a list of MoBackRow object from the relation JSON
        /// </summary>
        /// <returns>The back row from relation JSO.</returns>
        /// <param name="relationJSON">Relation JSO.</param>
        public static List <MoBackRow> MoBackRowFromRelationJSON(SimpleJSONNode relationJSON)
        {
            SimpleJSONArray nestedArray = relationJSON["value"] as SimpleJSONArray;

            List <MoBackRow> moBackRows = new List <MoBackRow>();

            // If the nested json doesn't have an object type, just return null.
            // When AchieveRelation without ?include={ColumnName}, it will return a pointer type.
            for (int i = 0; i < nestedArray.Count; i++)
            {
                if (nestedArray[i]["__type"].Value != "object")
                {
                    if (nestedArray[i]["__type"].Value == "Pointer")
                    {
                        Debug.LogWarning("The response JSON contains Pointer type, not Object type, can't parse this relationJson. Try MoBackRelation.RelationFromMoBackJSON() instead");
                        return(null);
                    }
                    else
                    {
                        Debug.LogError("Unknown type: " + nestedArray[i]["__type"].Value);
                        return(null);
                    }
                }

                SimpleJSONClass jsonObject = nestedArray[i] as SimpleJSONClass;

                // This will get the MoBackObject exlucde the 2 keys: "__type" and "className".
                moBackRows.Add(MoBackRow.FromJSON(jsonObject, nestedArray[i]["className"]));
            }

            return(moBackRows);
        }
Пример #2
0
            /// <summary>
            /// Gets the objects processor.
            /// </summary>
            /// <returns>A list of objects of the MoBackRow type converted from a JSON object.</returns>
            /// <param name="jsonObject">JSON object.</param>
            private List <MoBackRow> GetObjects_processor(SimpleJSONNode jsonObject)
            {
                List <MoBackRow> objects = new List <MoBackRow>();

                // TODO: this doesn't work. Need to double check later.
                SimpleJSONArray results = jsonObject["results"].AsArray;

                for (int i = 0; i < results.Count; i++)
                {
                    objects.Add(MoBackRow.FromJSON(results[i] as SimpleJSONClass, table.TableName));
                }

                return(objects);
            }
Пример #3
0
 /// <summary>
 /// Gets the object processor.
 /// </summary>
 /// <returns>The a MoBackRow converted from a JSON object.</returns>
 /// <param name="jsonObject">A JSON object.</param>
 private MoBackRow GetObject_processor(SimpleJSONNode jsonObject)
 {
     return(MoBackRow.FromJSON(jsonObject as SimpleJSONClass, table.TableName));
 }