Skip to content

Commit 722ae45

Browse files
fix: fixed json conversion from yaml to json (#102)
1 parent 7ebd2ee commit 722ae45

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

json/json.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ func writeJSONScalar(ctx *jsonWriteContext, node *yaml.Node) error {
368368
return nil
369369

370370
case "!!bool":
371-
// Booleans
372-
ctx.write(node.Value)
371+
// Booleans true/True/TRUE to true compatible with JSON
372+
ctx.write(strings.ToLower(node.Value))
373373
return nil
374374

375375
case "!!null":

json/json_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,20 @@ production:
211211
"host": "prod.example.com"
212212
}
213213
}
214+
`,
215+
indentation: 2,
216+
},
217+
{
218+
name: "booleans",
219+
yamlInput: `lowerCaseBool: true
220+
mixedCaseBool: True
221+
upperCaseBool: FALSE
222+
`,
223+
expectedJSON: `{
224+
"lowerCaseBool": true,
225+
"mixedCaseBool": true,
226+
"upperCaseBool": false
227+
}
214228
`,
215229
indentation: 2,
216230
},

0 commit comments

Comments
 (0)