Skip to content

Commit 9de5399

Browse files
committed
update README
1 parent 0d9cfc0 commit 9de5399

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

README.mbt.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,31 @@
1-
# jsondiff
1+
# jsondiff
2+
3+
Simple Json Structrual Diff Library
4+
5+
```mbt test
6+
let old : Json = {
7+
"foo": [1, 2, 3],
8+
"bar": { "baz": "qux" }
9+
}
10+
11+
let new : Json = {
12+
"foo": [1, 2, 4],
13+
"bar": { "baz": "quux" },
14+
"new_key": true
15+
}
16+
inspect(JsonDiff::diff_string(old, new).unwrap(), content=(
17+
#| {
18+
#|+ new_key: true
19+
#| foo: [
20+
#| 1
21+
#| 2
22+
#|- 3
23+
#|+ 4
24+
#| ]
25+
#| bar: {
26+
#|- baz: "qux"
27+
#|+ baz: "quux"
28+
#| }
29+
#| }
30+
))
31+
```

stringify.mbt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,7 @@ let output_colorful_text_for_terminal : Ref[Bool] = Ref::new(false)
9494
fn Array::push_line(self : Array[String], tag : String, line : String) -> Unit {
9595
let tagged_line = "\{tag}\{line}"
9696
if output_colorful_text_for_terminal.val {
97-
match tag {
98-
"+" =>
99-
// green
100-
self.push("\u{1b}[32m\{tag}\{line}\u{1b}[0m")
101-
"-" =>
102-
// red
103-
self.push("\u{1b}[31m\{tag}\{line}\u{1b}[0m")
104-
_ => self.push(tagged_line)
105-
}
97+
...
10698
} else {
10799
self.push(tagged_line)
108100
}

0 commit comments

Comments
 (0)