Class JsonObjectWriter
- Namespace
- NuGet.RuntimeModel
- Assembly
- Chocolatey.NuGet.Packaging.dll
Generates JSON from an object graph.
This is non-private only to facilitate unit testing.
public sealed class JsonObjectWriter : IObjectWriter, IDisposable
- Inheritance
-
JsonObjectWriter
- Implements
- Inherited Members
Constructors
JsonObjectWriter(JsonWriter)
public JsonObjectWriter(JsonWriter writer)
Parameters
writer
JsonWriter
Methods
Dispose()
public void Dispose()
WriteArrayEnd()
Writes the end of an array.
The parent object for this array becomes the scope for subsequent method calls. If this object is the root object, no further writing is allowed.
Every call to WriteArrayStart needs to be balanced with a corresponding call to WriteArrayEnd and not WriteObjectEnd.
public void WriteArrayEnd()
Exceptions
- ObjectDisposedException
Thrown if this object is disposed.
WriteArrayStart(string)
Writes the start of an array. The new object becomes the scope of all other methods until WriteArrayStart is called to start a new object in the array, or WriteArrayEnd is called. Every call to WriteArrayStart needs to be balanced with a corresponding call to WriteArrayEnd and not WriteObjectEnd.
public void WriteArrayStart(string name)
Parameters
name
stringThe array name
Exceptions
- ArgumentNullException
Thrown if
name
isnull
.- ObjectDisposedException
Thrown if this object is disposed.
WriteNameArray(string, IEnumerable<string>)
Writes a name-collection pair.
public void WriteNameArray(string name, IEnumerable<string> values)
Parameters
name
stringThe name of the data.
values
IEnumerable<string>The data.
Exceptions
- ArgumentNullException
Thrown if
name
isnull
.- ObjectDisposedException
Thrown if this object is disposed.
WriteNameValue(string, bool)
Writes a name-value pair.
public void WriteNameValue(string name, bool value)
Parameters
Exceptions
- ArgumentNullException
Thrown if
name
isnull
.- ObjectDisposedException
Thrown if this object is disposed.
WriteNameValue(string, int)
Writes a name-value pair.
public void WriteNameValue(string name, int value)
Parameters
Exceptions
- ArgumentNullException
Thrown if
name
isnull
.- ObjectDisposedException
Thrown if this object is disposed.
WriteNameValue(string, string)
Writes a name-value pair.
public void WriteNameValue(string name, string value)
Parameters
Exceptions
- ArgumentNullException
Thrown if
name
isnull
.- ObjectDisposedException
Thrown if this object is disposed.
WriteObjectEnd()
Writes the end of a nested object.
The parent object for this object becomes the scope for subsequent method calls. If this object is the root object, no further writing is allowed.
Every call to WriteObjectStart must be balanced by a corresponding call to WriteObjectEnd.
public void WriteObjectEnd()
Exceptions
- ObjectDisposedException
Thrown if this object is disposed.
WriteObjectStart()
Writes the start of the root object or an object in an array.
This new object becomes the scope for all other method calls until either WriteObjectStart is called again to start a new nested object or WriteObjectEnd is called.
Every call to WriteObjectStart must be balanced by a corresponding call to WriteObjectEnd.
public void WriteObjectStart()
Exceptions
- ObjectDisposedException
Thrown if this object is disposed.
WriteObjectStart(string)
Writes the start of a nested object.
This new object becomes the scope for all other method calls until either WriteObjectStart is called again to start a new nested object or WriteObjectEnd is called.
Every call to WriteObjectStart must be balanced by a corresponding call to WriteObjectEnd.
public void WriteObjectStart(string name)
Parameters
name
stringThe name of the object.
Exceptions
- ArgumentNullException
Thrown if
name
isnull
.- ObjectDisposedException
Thrown if this object is disposed.