Skip to content

Commit 7e99386

Browse files
committed
Merge pull request #2 from winny-/master
Add boolean support & some small project improvements
2 parents d36a25e + 15bcd60 commit 7e99386

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ json.scpt: json.applescript
33

44
test: json.scpt
55
osascript tests.applescript
6+
7+
.PHONY: test

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ end
1717
set json to load script (json_path as alias)
1818
```
1919

20-
Alternatively, just copy/paste the contens of `json.applescript` into
21-
your own script, and use it straigt away.
20+
Alternatively, just copy/paste the contents of `json.applescript` into
21+
your own script, and use it straight away.
2222

2323
### Usage
2424

json.applescript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
on encode(value)
22
set type to class of value
3-
if type = integer
3+
if type = integer or type = boolean
44
return value as text
55
else if type = text
66
return encodeString(value)

tests.applescript

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ assert_eq(json's hex4(65537), "0001")
2525
assert_eq(json's encode(1), "1")
2626
assert_eq(json's encode(0), "0")
2727

28+
assert_eq(json's encode(true), "true")
29+
assert_eq(json's encode(false), "false")
30+
2831
assert_eq(json's encode("foo"), "\"foo\"")
2932
assert_eq(json's encode(""), "\"\"")
3033
assert_eq(json's encode("\n"), "\"\\u000a\"")

0 commit comments

Comments
 (0)