Serialize as a single JSONL line (no pretty-printing, trailing newline).
(&self)
| 15 | |
| 16 | /// Serialize as a single JSONL line (no pretty-printing, trailing newline). |
| 17 | pub fn to_json_line(&self) -> Result<String, serde_json::Error> { |
| 18 | let mut line = serde_json::to_string(self)?; |
| 19 | line.push('\n'); |
| 20 | Ok(line) |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | #[cfg(test)] |