Skip to content

Commit 6e964fd

Browse files
committed
Fixed stringify of nested arrays and objects.
1 parent fef21f9 commit 6e964fd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,20 @@ function addPatternProperties (pp) {
137137
for (var i = 0; i < keys.length; i++) {
138138
if (properties[keys[i]]) continue
139139
`
140-
Object.keys(pp).forEach(regex => {
140+
Object.keys(pp).forEach((regex, index) => {
141141
var type = pp[regex].type
142-
if (type === 'integer') type = 'number'
143142
code += `
144143
if (/${regex}/.test(keys[i])) {
145144
`
146145
if (type === 'object') {
146+
code += buildObject(pp[regex], '', 'buildObjectPP' + index)
147147
code += `
148-
json += $asString(keys[i]) + ':{},'
148+
json += $asString(keys[i]) + ':' + buildObjectPP${index}(obj[keys[i]]) + ','
149149
`
150150
} else if (type === 'array') {
151+
code += buildArray(pp[regex], '', 'buildArrayPP' + index)
151152
code += `
152-
json += $asString(keys[i]) + ':[],'
153+
json += $asString(keys[i]) + ':' + buildArrayPP${index}(obj[keys[i]]) + ','
153154
`
154155
} else if (type === 'null') {
155156
code += `
@@ -232,7 +233,6 @@ function buildObject (schema, code, name) {
232233
`
233234

234235
code += laterCode
235-
236236
return code
237237
}
238238

0 commit comments

Comments
 (0)