Beispiel #1
0
        public JsonObject(JsonObject value)
        {
            switch (value._nodeObject.ElementType)
            {
            case JsonElementType.Dictionary:
                var prevDic = (Dictionary <string, object>)value._nodeObject.FinishObj;
                var newDic  = GetCopy(prevDic);
                _nodeObject = new JsonNodeObject(newDic);
                return;

            case JsonElementType.List:
                var prevList = (List <object>)value._nodeObject.FinishObj;
                var newList  = GetCopy(prevList);
                _nodeObject = new JsonNodeObject(newList);
                return;

            case JsonElementType.Long:
            case JsonElementType.Double:
            case JsonElementType.Bool:
            case JsonElementType.String:
                _nodeObject = new JsonNodeObject(value._nodeObject);
                break;

            case JsonElementType.Null:
                throw new ArgumentOutOfRangeException();

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Beispiel #2
0
        private void CreateJsonObject(object jsonObj)
        {
            var elem = GetTypeOfElement(jsonObj);
            //Debug.Log("elem: " + elem);
            var node = GetJsonFinishNode(elem);

            //Debug.Log("node: " + node);

            if (node == JsonFinishNode.Null)
            {
                return;
            }

            _nodeObject = new JsonNodeObject
            {
                FinishObj   = jsonObj,
                ElementType = elem
            };

            switch (node)
            {
            case JsonFinishNode.List:
                CreateListJsonObject(jsonObj);
                break;

            case JsonFinishNode.Dict:
                CreateDictionaryJsonObject(jsonObj);
                break;

            case JsonFinishNode.Finish:
                break;

            case JsonFinishNode.Null:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Beispiel #3
0
 public JsonObject(string value)
 {
     _nodeObject = new JsonNodeObject(value);
 }
Beispiel #4
0
 public JsonObject(double value)
 {
     _nodeObject = new JsonNodeObject(value);
 }
Beispiel #5
0
 public JsonObject(bool value)
 {
     _nodeObject = new JsonNodeObject(value);
 }
 public JsonNodeObject(JsonNodeObject node)
 {
     FinishObj   = node.FinishObj;
     ElementType = node.ElementType;
 }