Libraryless. Click here for Pure Java version (5837L/34K).
1 | sS nicelyFormatJsonDiff(O diff) { |
2 | new StringBuilderWithIndent buf; |
3 | nicelyFormatJsonDiff(diff, buf); |
4 | ret str(buf); |
5 | } |
6 | |
7 | svoid nicelyFormatJsonDiff(O diff, StringBuilderWithIndent buf) { |
8 | if (diff == null) ret with buf.println("No differences"); |
9 | if (diff cast JsonDiff.Removed) |
10 | ret with buf.println("DELETE " + diff.a); |
11 | if (diff cast JsonDiff.Added) |
12 | ret with buf.println("ADD " + diff.b); |
13 | if (diff cast JsonDiff.Different) // also covers DifferentType |
14 | ret with buf.println(diff.a + " -> " + diff.b); |
15 | if (diff cast Map<O>) { |
16 | for (O key, O value : diff) { |
17 | if (!value instanceof JsonDiff.Different |
18 | || !key instanceof JsonDiff.GatheredKey) |
19 | if (key cast JsonDiff.GatheredKey) { |
20 | buf.println(key.key + "=" + key.value); |
21 | } else |
22 | buf.println(key); |
23 | temp buf.indent(); |
24 | nicelyFormatJsonDiff(value, buf); |
25 | } |
26 | ret; |
27 | } |
28 | buf.println(sfu(diff)); // something unknown |
29 | } |
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1026307 |
Snippet name: | nicelyFormatJsonDiff |
Eternal ID of this version: | #1026307/15 |
Text MD5: | 0250e7c86d193cf9cc94ca0220f02ede |
Transpilation MD5: | 06401e886b82ab52a3d026556f243145 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-09-02 04:32:36 |
Source code size: | 975 bytes / 29 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 242 / 401 |
Version history: | 14 change(s) |
Referenced in: | [show references] |