| 252 | } |
| 253 | |
| 254 | Status JsonWriter::WriteValue(sj::value value) { |
| 255 | return VisitJsonValue( |
| 256 | value, |
| 257 | |
| 258 | [&](sj::object object) -> Status { |
| 259 | StartObject(); |
| 260 | |
| 261 | for (auto field : object) { |
| 262 | ARROW_ASSIGN_OR_RAISE( |
| 263 | auto key, |
| 264 | ResolveSimdjsonResult(field.unescaped_key(), "Failed to get object key")); |
| 265 | |
| 266 | Key(key); |
| 267 | |
| 268 | ARROW_ASSIGN_OR_RAISE( |
| 269 | auto field_value, |
| 270 | ResolveSimdjsonResult(field.value(), "Failed to get object value")); |
| 271 | |
| 272 | RETURN_NOT_OK(WriteValue(field_value)); |
| 273 | } |
| 274 | |
| 275 | EndObject(); |
| 276 | return Status::OK(); |
| 277 | }, |
| 278 | |
| 279 | [&](sj::array array) -> Status { |
| 280 | StartArray(); |
| 281 | |
| 282 | for (auto element : array) { |
| 283 | ARROW_ASSIGN_OR_RAISE( |
| 284 | auto element_value, |
| 285 | ResolveSimdjsonResult(element, "Failed to iterate JSON array")); |
| 286 | |
| 287 | RETURN_NOT_OK(WriteValue(element_value)); |
| 288 | } |
| 289 | |
| 290 | EndArray(); |
| 291 | return Status::OK(); |
| 292 | }, |
| 293 | |
| 294 | [&](std::string_view string_value) -> Status { |
| 295 | String(string_value); |
| 296 | return Status::OK(); |
| 297 | }, |
| 298 | |
| 299 | [&](bool bool_value) -> Status { |
| 300 | Bool(bool_value); |
| 301 | return Status::OK(); |
| 302 | }, |
| 303 | |
| 304 | [&]() -> Status { |
| 305 | Null(); |
| 306 | return Status::OK(); |
| 307 | }, |
| 308 | |
| 309 | [&](int64_t value) -> Status { |
| 310 | Int64(value); |
| 311 | return Status::OK(); |