Example #1
0
        /// <summary>
        /// Convert the object to JSON format.
        /// </summary>
        /// <returns>A string representation of this object, serialized to JSON.</returns>
        /// <summary>
        /// Converts this Scene to a compatible JSON format.
        /// </summary>
        /// <returns>JSON String.</returns>
        public virtual string ToJSON(bool format)
        {
            SerializationAdaptor             = new Object3DSerializationAdaptor();
            SerializationAdaptor.Object.Name = Name;

            ProcessChildren();

            return(JsonConvert.SerializeObject(SerializationAdaptor, format == true ? Formatting.Indented : Formatting.None, new JsonSerializerSettings {
                DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore
            }));
        }
Example #2
0
        /// <summary>
        /// Convert the object to JSON format.
        /// </summary>
        /// <returns>A string representation of this object, serialized to JSON.</returns>
        /// <summary>
        /// Converts this Scene to a compatible JSON format.
        /// </summary>
        /// <returns>JSON String.</returns>
        public virtual string ToJSON(bool format)
        {
            SerializationAdaptor             = new Object3DSerializationAdaptor();
            SerializationAdaptor.Object.Name = Name;

            ProcessChildren();

            var serializerSettings = new JsonSerializerSettings
            {
                Formatting           = format == true ? Formatting.Indented : Formatting.None,
                DefaultValueHandling = DefaultValueHandling.Ignore,
                NullValueHandling    = NullValueHandling.Ignore,
                ContractResolver     = new CamelCaseCustomResolver()
            };

            return(JsonConvert.SerializeObject(SerializationAdaptor, serializerSettings));
        }