* Encodes an Array object into JSON and writes it to the output stream. * * @param array The Array object to be serialized into JSON. * @param yc The optional yield context for asynchronous operations. If provided, it allows the encoder * to flush the output stream safely when it has not acquired any object lock. */
| 101 | * to flush the output stream safely when it has not acquired any object lock. |
| 102 | */ |
| 103 | void JsonEncoder::EncodeArray(const Array::Ptr& array, boost::asio::yield_context* yc) |
| 104 | { |
| 105 | BeginContainer('['); |
| 106 | auto olock = array->LockIfRequired(); |
| 107 | if (olock) { |
| 108 | yc = nullptr; // We've acquired an object lock, never allow asynchronous operations. |
| 109 | } |
| 110 | |
| 111 | bool isEmpty = true; |
| 112 | for (const auto& item : array) { |
| 113 | WriteSeparatorAndIndentStrIfNeeded(!isEmpty); |
| 114 | isEmpty = false; |
| 115 | Encode(item, yc); |
| 116 | m_Flusher.FlushIfSafe(yc); |
| 117 | } |
| 118 | EndContainer(']', isEmpty); |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Encodes a ValueGenerator object into JSON and writes it to the output stream. |
nothing calls this directly
no test coverage detected