From 188f4b0e65729cd39ae3a58e5241bc0e871946a7 Mon Sep 17 00:00:00 2001 From: Davy Landman Date: Thu, 25 Apr 2024 11:25:15 +0200 Subject: [PATCH] Improved heuristic to favor an empty json object in case of an empty map --- .../library/lang/json/internal/JsonValueWriter.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/org/rascalmpl/library/lang/json/internal/JsonValueWriter.java b/src/org/rascalmpl/library/lang/json/internal/JsonValueWriter.java index 8fc7452cd91..c20838b972f 100644 --- a/src/org/rascalmpl/library/lang/json/internal/JsonValueWriter.java +++ b/src/org/rascalmpl/library/lang/json/internal/JsonValueWriter.java @@ -253,7 +253,11 @@ public Void visitInteger(IInteger o) throws IOException { @Override public Void visitMap(IMap o) throws IOException { - if (o.getKeyType().isString()) { + if (o.isEmpty()) { + out.beginObject(); + out.endObject(); + } + else if (o.getKeyType().isString()) { out.beginObject(); for (IValue key : o) { out.name(((IString) key).getValue());