Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty printing arrays yields invalid json #46

Closed
potmo opened this issue Oct 6, 2015 · 0 comments
Closed

Pretty printing arrays yields invalid json #46

potmo opened this issue Oct 6, 2015 · 0 comments

Comments

@potmo
Copy link
Contributor

potmo commented Oct 6, 2015

pretty printing a .JSArray is missing the opening brace like:

"something": 
{
   "a": "a",
   "b": "b",
   "c": "c"
}
]

when this is expected

"something": 
[
{
   "a": "a",
   "b": "b",
   "c": "c"
}
]

A possible fix is to replace line 251 of JSValue with:
case .JSArray(let array): return "[\(newline)" + (array.map({ "\(nextIndent)\($0.prettyPrint(indent, level + 1))" })) .joinWithSeparator(",\(newline)") + "\(newline)\(currentIndent)]"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants