public static string Serialise(object obj)
        {
            var jsonObject = new JsonObject(obj);
            var json = "{";

            var first = true;
            foreach (var field in jsonObject.Fields)
            {
                var jsonField = SerialiseField(field);
                if (jsonField == String.Empty)
                {
                    continue;
                }
                if (!first)
                {
                    json += ",";
                }
                json += jsonField;
                first = false;
            }

            return json + "}";
        }
        private static string SerialiseField(KeyValuePair<string, object> field)
        {
            if (field.Value == null)
            {
                return String.Empty;
            }

            if (IsPrimitive(field.Value))
            {
                return "\"" + field.Key + "\":" + field.Value;
            }

            var jsonObject = new JsonObject(field.Value);
            if (jsonObject.Count > 0)
            {
                if (jsonObject.HasVisibleFields)
                {
                    return "\"" + field.Key + "\":" + Serialise(field.Value);
                }
                return String.Empty;
            }

            return "\"" + field.Key + "\":\"" + field.Value + "\"";
        }