Skip to content

Commit d54a689

Browse files
committed
Properly handle JSON booleans
- Fixes #5
1 parent 7b58c50 commit d54a689

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

json-to-multicsv.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ sub grovel {
226226
if (defined $handler and $handler->{kind} eq 'ignore') {
227227
return;
228228
}
229-
if (!defined $val or !ref $val) {
229+
if (!defined $val or !ref $val or JSON::is_bool $val) {
230230
record $val;
231231
} elsif ('HASH' eq ref $val) {
232232
die "Don't know how to handle object at $path. Suggestions:\n --path $path:table:name\n --path $path:column\n --path $path:row\n --path $path:ignore\n" if !$handler;

test/basic/input.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"item 1": {
33
"title": "The First Item",
44
"genres": ["sci-fi", "adventure"],
5+
"available": true,
56
"rating": {
67
"mean": 9.5,
78
"votes": 190
@@ -20,6 +21,7 @@
2021
"item 2": {
2122
"title": "The Second Item",
2223
"genres": ["history", "economics"],
24+
"available": false,
2325
"rating": {
2426
"mean": 7.4,
2527
"votes": 865

test/basic/output.expected/item.csv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
item._key,item.rating.mean,item.rating.votes,item.title
2-
"item 1",9.5,190,"The First Item"
3-
"item 2",7.4,865,"The Second Item"
1+
item._key,item.available,item.rating.mean,item.rating.votes,item.title
2+
"item 1",1,9.5,190,"The First Item"
3+
"item 2",0,7.4,865,"The Second Item"

0 commit comments

Comments
 (0)