MCPcopy Create free account
hub / github.com/apache/datafusion / validate_complete

Method validate_complete

datafusion/datasource-json/src/utils.rs:173–205  ·  view source on GitHub ↗

Check if the JSON array was properly terminated. This should be called after all data has been read. Returns an error if: - Unbalanced braces/brackets (depth != 0) - Unterminated string - Missing closing `]` - Unexpected trailing content after `]`

(&self)

Source from the content-addressed store, hash-verified

171 /// - Missing closing `]`
172 /// - Unexpected trailing content after `]`
173 pub fn validate_complete(&self) -> std::io::Result<()> {
174 if self.has_leading_content {
175 return Err(std::io::Error::new(
176 std::io::ErrorKind::InvalidData,
177 "Malformed JSON: unexpected leading content before '['",
178 ));
179 }
180 if self.depth != 0 {
181 return Err(std::io::Error::new(
182 std::io::ErrorKind::InvalidData,
183 "Malformed JSON array: unbalanced braces or brackets",
184 ));
185 }
186 if self.in_string {
187 return Err(std::io::Error::new(
188 std::io::ErrorKind::InvalidData,
189 "Malformed JSON array: unterminated string",
190 ));
191 }
192 if self.state != JsonArrayState::Done {
193 return Err(std::io::Error::new(
194 std::io::ErrorKind::InvalidData,
195 "Incomplete JSON array: expected closing bracket ']'",
196 ));
197 }
198 if self.has_trailing_content {
199 return Err(std::io::Error::new(
200 std::io::ErrorKind::InvalidData,
201 "Malformed JSON: unexpected trailing content after ']'",
202 ));
203 }
204 Ok(())
205 }
206
207 /// Process a single byte and return the transformed byte (if any)
208 #[inline]

Calls 1

newFunction · 0.85