Class JsonBlock
- Namespace
- GenerativeAI.Core
- Assembly
- GenerativeAI.dll
Represents a block of JSON data with associated metadata.
public class JsonBlock
- Inheritance
-
JsonBlock
- Inherited Members
- Extension Methods
Constructors
JsonBlock()
Represents a block of JSON data along with its associated line number
public JsonBlock()
JsonBlock(string, int, bool)
Represents a block of JSON data along with its associated line number.
public JsonBlock(string json, int lineNumber = 0, bool isArray = false)
Parameters
Properties
IsArray
Gets or sets a value indicating whether the JSON content represents an array.
public bool IsArray { get; set; }
Property Value
Json
Gets or sets the JSON content represented as a string.
public string Json { get; set; }
Property Value
LineNumber
Gets or sets the line number associated with the JSON block.
public int LineNumber { get; set; }
Property Value
Remarks
This property represents the specific line number in a source or context that corresponds to the JSON data represented by the object.
Methods
ToObject<T>(JsonSerializerOptions?)
Deserializes the JSON data of the current instance into an object of type T.
public T? ToObject<T>(JsonSerializerOptions? options = null) where T : class
Parameters
optionsJsonSerializerOptionsOptional JsonSerializerOptions to configure the deserialization process. Default options will be used if not provided.
Returns
- T
An instance of type
Tif deserialization is successful; otherwise, null in case of an error.
Type Parameters
TThe type of object to which the JSON data will be deserialized. Must be a class.
Remarks
For NativeAOT/Trimming JsonSerializerOptions are required, you can ignore it if you have already specified a resolver in