public static void Serialize(object obj, JsonOptions options, StringBuilder resultStore)
        {
            options.ThrowIfNull(nameof(options));
            resultStore.ThrowIfNull(nameof(resultStore));
            SerializationSettings serializationSettings = new SerializationSettings(resultStore);

            serializationSettings.ApplyOptions(options);

            ToJson(obj, serializationSettings);
        }
        /// <summary>
        /// Serialize the object to a JSON-string.
        /// </summary>
        /// <param name="obj">Object to serialize.</param>
        /// <param name="options">Options to modify the string output behaviour.</param>
        /// <returns>A JSON representation of the given object.</returns>
        public static string Serialize(object obj, JsonOptions options = null)
        {
            SerializationSettings serializationSettings = new SerializationSettings();

            if (options != null)
            {
                serializationSettings.ApplyOptions(options);
            }

            ToJson(obj, serializationSettings);
            return(serializationSettings.resultStore.ToString());
        }
        /// <summary>
        /// Serialize the object to a JSON string and store the result directly in the result store.
        /// </summary>
        /// <param name="obj">Object to serialize.</param>
        /// <param name="resultStore">Write cache for the JSON result.</param>
        /// <param name="options">Options to modify the string output behaviour.</param>
        public static void Serialize(object obj, StringBuilder resultStore, JsonOptions options = null)
        {
            resultStore.ThrowIfNull(nameof(resultStore));

            SerializationSettings serializationSettings = new SerializationSettings(resultStore);

            if (options != null)
            {
                serializationSettings.ApplyOptions(options);
            }

            ToJson(obj, serializationSettings);
        }
 /// <summary>
 /// Process a JSON string value and attempt to deserialize it to an instance of the target type.
 /// </summary>
 /// <param name="jsonStr">JSON representation of an object.</param>
 /// <param name="options">Additional options to customize the deserialization behaviour.</param>
 /// <typeparam name="TTarget">Target type.</typeparam>
 public static TTarget Deserialize <TTarget>(string jsonStr, JsonOptions options = null)
 {
     return((TTarget)Deserialize(typeof(TTarget), jsonStr, options));
 }
        /// <summary>
        /// Process a JSON string value and attempt to deserialize it to an instance of the target type.
        /// </summary>
        /// <param name="targetType">Target type.</param>
        /// <param name="jsonStr">JSON representation of an object.</param>
        /// <param name="options">Additional options to customize the deserialization behaviour.</param>
        public static object Deserialize(Type targetType, string jsonStr, JsonOptions options = null)
        {
            ISerializationDefinition sd = (options?.SerializationDefinition != null) ? options.SerializationDefinition : defaultSerializationDefinition;

            return(Serializer.Deserialize(targetType, Deserialize(jsonStr, options), sd));
        }