Move SSD empty JSON defaults to typed Kotlin
ober
0f1e6cf57fd960dbacbbf14d57fceb6072bd4798
--- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -1593,7 +1593,7 @@ (typed-kotlin-file "com/sfb/ssdreview/TruthJson.kt" (kotlin-imports (org json JSONArray) (org json JSONObject)) (typed-library (com sfb ssdreview) - (export jsonObjectFromText + (export emptyJsonObject jsonObjectFromText truthJsonArrayOrEmpty truthJsonObjectOrEmpty truthGroupCount nullableTruthGroupCount truthSsdAreaRect truthSourceKey truthSessionIdOr @@ -1602,6 +1602,8 @@ (type JSONObject) (type FloatArray) (type Int32) + (def (emptyJsonObject) : JSONObject + (json-object-empty)) (def (jsonObjectFromText (text : String)) : JSONObject (json-object-from-string text)) (def (truthJsonArrayOrEmpty (raw : (Nullable JSONArray))) : JSONArray @@ -5682,7 +5684,7 @@ " }" " }" "" - " private fun logClientEvent(event: String, fields: JSONObject = JSONObject()) {" + " private fun logClientEvent(event: String, fields: JSONObject = emptyJsonObject()) {" " val payload = try { clientLogPayload(event, fields) } catch (_: Exception) { return }" " thread {" " try { sendClientLog(payload, CLIENT_LOG_READ_TIMEOUT_MS) } catch (_: Exception) { }" @@ -6647,7 +6649,7 @@ " return truthFile" " }" "" - " fun appendEvent(type: String, session: SsdSession, details: JSONObject = JSONObject()) {" + " fun appendEvent(type: String, session: SsdSession, details: JSONObject = emptyJsonObject()) {" " val event = sessionEventJson(type, session, details)" " appendJsonLine(containedLeaf(eventsDir, \"events-${sha256Hex(session.sessionId.toByteArray())}.events.jsonl\"), event)" " appendJsonLine(containedLeaf(eventsDir, \"all-events.jsonl\"), event)"