@@ -70,47 +70,83 @@ public static async ValueTask EncodeAsync(Stream utf8Stream, JsonElement element
7070 }
7171
7272 // Json(Array) to Toon(TabularArray)
73-
74- public static string EncodeAsTabularArray ( JsonElement element )
73+
74+ /// <summary>
75+ /// Encodes a JSON array of objects as a tabular array.
76+ /// </summary>
77+ /// <remarks>All objects in the input array must have identical property names in the same order, and all
78+ /// property values must be Toon primitive types.</remarks>
79+ /// <param name="array">A JsonElement representing an array of objects to encode as a tabular array. Each object must have the same
80+ /// property names in the same order.</param>
81+ /// <exception cref="ArgumentException">Thrown if the provided JsonElement is not an array, if any element in the array is not an object, if objects
82+ /// have differing property names or counts, or if any property value is not a Toon primitive.</exception>
83+ public static string EncodeAsTabularArray ( JsonElement array )
7584 {
7685 var bufferWriter = new ValueArrayPoolBufferWriter < byte > ( ) ;
7786 try
7887 {
79- EncodeAsTabularArray ( ref bufferWriter , element ) ;
88+ EncodeAsTabularArray ( ref bufferWriter , array ) ;
8089 return Encoding . UTF8 . GetString ( bufferWriter . WrittenSpan ) ;
8190 }
8291 finally
8392 {
8493 bufferWriter . Dispose ( ) ;
8594 }
8695 }
87-
88- public static void EncodeAsTabularArray < TBufferWriter > ( ref TBufferWriter bufferWriter , JsonElement element )
96+
97+ /// <summary>
98+ /// Encodes a JSON array of objects as a tabular array.
99+ /// </summary>
100+ /// <remarks>All objects in the input array must have identical property names in the same order, and all
101+ /// property values must be Toon primitive types.</remarks>
102+ /// <param name="array">A JsonElement representing an array of objects to encode as a tabular array. Each object must have the same
103+ /// property names in the same order.</param>
104+ /// <exception cref="ArgumentException">Thrown if the provided JsonElement is not an array, if any element in the array is not an object, if objects
105+ /// have differing property names or counts, or if any property value is not a Toon primitive.</exception>
106+ public static void EncodeAsTabularArray < TBufferWriter > ( ref TBufferWriter bufferWriter , JsonElement array )
89107 where TBufferWriter : IBufferWriter < byte >
90108 {
91109 var toonWriter = ToonWriter . Create ( ref bufferWriter ) ;
92- EncodeAsTabularArray ( ref toonWriter , element ) ;
110+ EncodeAsTabularArray ( ref toonWriter , array ) ;
93111 toonWriter . Flush ( ) ;
94112 }
95-
96- public static byte [ ] EncodeAsTabularArrayToUtf8Bytes ( JsonElement element )
113+
114+ /// <summary>
115+ /// Encodes a JSON array of objects as a tabular array.
116+ /// </summary>
117+ /// <remarks>All objects in the input array must have identical property names in the same order, and all
118+ /// property values must be Toon primitive types.</remarks>
119+ /// <param name="array">A JsonElement representing an array of objects to encode as a tabular array. Each object must have the same
120+ /// property names in the same order.</param>
121+ /// <exception cref="ArgumentException">Thrown if the provided JsonElement is not an array, if any element in the array is not an object, if objects
122+ /// have differing property names or counts, or if any property value is not a Toon primitive.</exception>
123+ public static byte [ ] EncodeAsTabularArrayToUtf8Bytes ( JsonElement array )
97124 {
98125 var bufferWriter = new ValueArrayPoolBufferWriter < byte > ( ) ;
99126 try
100127 {
101- EncodeAsTabularArray ( ref bufferWriter , element ) ;
128+ EncodeAsTabularArray ( ref bufferWriter , array ) ;
102129 return bufferWriter . WrittenSpan . ToArray ( ) ;
103130 }
104131 finally
105132 {
106133 bufferWriter . Dispose ( ) ;
107134 }
108- }
109-
110- public static async ValueTask EncodeAsTabularArrayAsync ( Stream utf8Stream , JsonElement element , CancellationToken cancellationToken = default )
135+ }
136+
137+ /// <summary>
138+ /// Encodes a JSON array of objects as a tabular array.
139+ /// </summary>
140+ /// <remarks>All objects in the input array must have identical property names in the same order, and all
141+ /// property values must be Toon primitive types.</remarks>
142+ /// <param name="array">A JsonElement representing an array of objects to encode as a tabular array. Each object must have the same
143+ /// property names in the same order.</param>
144+ /// <exception cref="ArgumentException">Thrown if the provided JsonElement is not an array, if any element in the array is not an object, if objects
145+ /// have differing property names or counts, or if any property value is not a Toon primitive.</exception>
146+ public static async ValueTask EncodeAsTabularArrayAsync ( Stream utf8Stream , JsonElement array , CancellationToken cancellationToken = default )
111147 {
112148 var writer = PipeWriter . Create ( utf8Stream ) ;
113- EncodeAsTabularArray ( ref writer , element ) ;
149+ EncodeAsTabularArray ( ref writer , array ) ;
114150 await writer . FlushAsync ( cancellationToken ) ;
115151 }
116152
0 commit comments