Skip to content

Commit

Permalink
improved json display and validation
Browse files Browse the repository at this point in the history
  • Loading branch information
rainer-prosi committed Oct 11, 2024
1 parent de48c2b commit 7fcc159
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/main/java/org/cip4/tools/jdfeditor/EditorDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -770,20 +770,28 @@ String getJSONString(final KElement root, final int indent)
final List<JSONObject> l = jw.splitConvert(root);
for (final JSONObject o : l)
{
final JSONIndentWalker iw = new JSONIndentWalker(new JSONObjHelper(o));
iw.setSingleIndent(indent);
iw.setSorted(true);
final ByteArrayIOStream ios = new ByteArrayIOStream();
try
if (indent > 0)
{
iw.writeStream(ios);
final JSONIndentWalker iw = new JSONIndentWalker(new JSONObjHelper(o));
iw.setSingleIndent(indent);
iw.setSorted(true);
iw.setRetainNull(true);
final ByteArrayIOStream ios = new ByteArrayIOStream();
try
{
iw.writeStream(ios);
}
catch (final IOException e)
{
continue;
}
final String s = new String(ios.toByteArray());
return s.trim();
}
catch (final IOException e)
else
{
continue;
return o.toJSONString();
}
final String s = new String(ios.toByteArray());
return s;
}
return null;
}
Expand Down

0 comments on commit 7fcc159

Please sign in to comment.