SimpleJSON.JSONNode.Add C# (CSharp) Method

Add() public method

public Add ( JSONNode aItem ) : void
aItem JSONNode
return void
		public virtual void Add(JSONNode aItem)
		{
			Add("", aItem);
		}

Same methods

JSONNode::Add ( string aKey, JSONNode aItem ) : void

Usage Example

    /**
     * This function converts the requested stored gesture into a JSON string containing the gesture name and training data.
     *
     * Gestures exported using this function can be re-imported using the fromJSON function below.
     *
     * @param gestureName
     * @returns {String}
     */
    string toJSON(string gestureName)
    {
        var gestures = this.gestures[gestureName];


        SimpleJSON.JSONNode json = new SimpleJSON.JSONNode(),
                            name = new SimpleJSON.JSONNode(),
                            pose = new SimpleJSON.JSONNode(),
                            data = new SimpleJSON.JSONNode(),
                            x, y, z, stroke;

        foreach (var gesture in gestures)
        {
            SimpleJSON.JSONNode gesturePoints = new SimpleJSON.JSONNode();

            foreach (var point in gesture)
            {
                SimpleJSON.JSONNode pointComponents = new SimpleJSON.JSONNode();

                x      = new SimpleJSON.JSONNode(); x.AsFloat = point.x;
                y      = new SimpleJSON.JSONNode(); y.AsFloat = point.y;
                z      = new SimpleJSON.JSONNode(); z.AsFloat = point.z;
                stroke = new SimpleJSON.JSONNode(); stroke.AsFloat = point.stroke;

                pointComponents.Add("x", x);
                pointComponents.Add("y", y);
                pointComponents.Add("z", z);
                pointComponents.Add("stroke", stroke);

                gesturePoints.Add(pointComponents);
            }

            data.Add(gesturePoints);
        }


        name.Value  = gestureName;
        pose.AsBool = this.poses[gestureName];

        json.Add("name", name);
        json.Add("pose", pose);
        json.Add("data", data);

        return(json.ToString());
    }
All Usage Examples Of SimpleJSON.JSONNode::Add