json without line breaks

This commit is contained in:
Alexander Bentkamp
2022-10-19 09:40:30 +02:00
parent fd2af2fd24
commit 94a9295554
+12 -3
View File
@@ -11,9 +11,18 @@ import GameServer.EnvExtensions
open Lean Meta Elab Tactic Std
/- Convert JSON to string without line breaks -/
-- TODO: this is too slow...
instance instToStringJsonOneLine : ToString Json := ToString.mk (fun o => (toString o).replace "\n" "")
/-- Convert format to string without line breaks -/
def Std.Format.oneline : Format → String
| .nil => ""
| .line => ""
| .text s => s
| .nest _ f => f.oneline
| .append f g => f.oneline ++ g.oneline
| .group f _ => f.oneline
| .tag _ f => f.oneline
/-- Convert JSON to string without line breaks -/
instance instToStringJsonOneLine : ToString Json := ⟨fun o => o.render.oneline⟩
attribute [-instance] Lean.Json.instToStringJson
/-! ## GameGoal -/