Skip to content

Multi-line string support #82

Closed
Closed
@normanr

Description

@normanr

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:

>>> foo='''{
... "key": "value
... over two lines",
... }'''
>>> import json5
>>> json5.version.VERSION
'0.9.25'
>>> json5.loads(foo)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../site-packages/json5/lib.py", line 108, in loads
    raise ValueError(err)
ValueError: <string>:2 Unexpected "
" at column 14

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 😞

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions