/// <summary> /// Writes a property container to a json string. /// </summary> /// <param name="container">The container to write.</param> /// <param name="visitor">The visitor to use. If none is provided, the default one is used.</param> /// <typeparam name="TContainer">The type to serialize.</typeparam> /// <returns>A json string.</returns> public static string Serialize <TContainer>(TContainer container, JsonVisitor visitor = null) { if (null == visitor) { visitor = s_DefaultVisitor; } visitor.Builder.Clear(); WritePrefix(visitor); PropertyContainer.Visit(container, visitor); WriteSuffix(visitor); return(visitor.Builder.ToString()); }
static void WriteSuffix(JsonVisitor visitor) { visitor.Indent--; if (visitor.Builder[visitor.Builder.Length - 2] == '{') { visitor.Builder.Length -= 1; } else { visitor.Builder.Length -= 2; } visitor.Builder.Append("\n"); visitor.Builder.Append(' ', JsonVisitor.Style.Space * visitor.Indent); visitor.Builder.Append("}"); }
public JsonVisitorAdapterUnityEngine(JsonVisitor visitor) : base(visitor) { }
public JsonPrimitiveAdapter(JsonVisitor visitor) : base(visitor) { }
static void WritePrefix(JsonVisitor visitor) { visitor.Builder.Append(' ', JsonVisitor.Style.Space * visitor.Indent); visitor.Builder.Append("{\n"); visitor.Indent++; }
public JsonVisitorAdapterPrimitives(JsonVisitor visitor) : base(visitor) { }
/// <summary> /// Initializes a new instance of <see cref="JsonVisitorAdapter"/>. /// </summary> /// <param name="visitor">The <see cref="JsonVisitor"/> this adapter was added to.</param> protected JsonVisitorAdapter(JsonVisitor visitor) { m_Visitor = visitor; }
public JsonVisitorAdapterUnityEditor(JsonVisitor visitor) : base(visitor) { }
public JsonVisitorAdapterSystemIO(JsonVisitor visitor) : base(visitor) { }
/// <summary> /// Serializes this object to a JSON string. /// </summary> /// <param name="visitor">Optional visitor used for serialization.</param> /// <returns>The created JSON string.</returns> public string Serialize(JsonVisitor visitor = null) { return(JsonSerialization.Serialize(this, visitor)); }