/// <summary>
        /// Build a JSON string from the event data
        /// </summary>
        /// <returns></returns>
        public String ToJSON()
        {
            // Create a json object from this event and then stringigy it
            JSONObject json = new JSONObject();
            json.AddField("jsonrpc", "2.0");

            // We always use id 1, no async tasks are required
            json.AddField("id", 1);

            // Add metod name
            json.AddField("method", GetMethodName());
            json.AddField("params", GetParams());

            return json.ToString();
        }
Exemplo n.º 2
0
 static void MergeRecur(JSONObject left, JSONObject right)
 {
     if (right.type == JSONObject.Type.OBJECT)
     {
         for (int i = 0; i < right.list.Count; i++)
         {
             if (right.keys[i] != null)
             {
                 string key = (string)right.keys[i];
                 JSONObject val = (JSONObject)right.list[i];
                 if (val.type == JSONObject.Type.ARRAY || val.type == JSONObject.Type.OBJECT)
                 {
                     if (left.HasField(key))
                         MergeRecur(left[key], val);
                     else
                         left.AddField(key, val);
                 }
                 else
                 {
                     if (left.HasField(key))
                         left.SetField(key, val);
                     else
                         left.AddField(key, val);
                 }
             }
         }
     }// else left.list.Add(right.list);
 }