-
Notifications
You must be signed in to change notification settings - Fork 31
Multi-line string support #82
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
Comments
Hi! Per the spec, multiline strings in JSON5 (and Javascript, unless you're using template literals) require a line continuation mark ("") at the end of the line to work:
So, what you're trying to do by default won't work. However, it's generally my intent for |
I think adding a Unfortunately I don't control the json I'm parsing and I know it's malformed, but "the Newtonsoft.Json c# parser can parse it fine", so I'm trying to find a Python based parser that can do the same (at least consume the input without raising an exception). Note that Newtonsoft.Json, doesn't seem to handle line continuation at all: https://dotnetfiddle.net/lHgHvp, but I'm fine with the parsing result being different between Python and c# as I'm not reading the field with the raw newlines anyways. |
Yup, I'll have a fix for this posted in a little bit, just need to write some tests ... :). |
Okay, fixed now in version v0.9.26. |
I'm trying to get multi-line strings (from input I don't control) to work (the README claims "multi-line string literals are allowed", so I'm assuming it should work), but it doesn't seem to:
The built in python json library does support multi-line strings (with
strict=False
), but can't handle the trailing comma (which is why I'm using json5).Is there an option to support this? Am I doing something wrong?
Context: I'm trying to parse user data that's currently being parsed with the Newtonsoft.Json c# parser. It seems to accept bare-newlines in json strings 😞
The text was updated successfully, but these errors were encountered: