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

BUG: Line delimited json is breaks if string includes } #14390

Closed
joshowen opened this issue Oct 10, 2016 · 1 comment
Closed

BUG: Line delimited json is breaks if string includes } #14390

joshowen opened this issue Oct 10, 2016 · 1 comment
Labels
Bug IO JSON read_json, to_json, json_normalize
Milestone

Comments

@joshowen
Copy link

In 0.19.0 exporting json with new lines breaks if a string contains a closing curly brace.

Example

import pandas as pd
pd.DataFrame([{'a': 'foo}', 'b': 'bar'}, {'a': 'foo2', 'b': 'bar2'}]).to_json(orient='records', lines=True)

'{"a":"foo}"\n"b":"bar"},{"a":"foo2"\n"b":"bar2"}'

Expected Output

'{"a":"foo}","b":"bar"}\n{"a":"foo2","b":"bar2"}'

Output of pd.show_versions()

## INSTALLED VERSIONS

commit: None
python: 2.7.12.final.0
python-bits: 64
OS: Darwin
OS-release: 16.0.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.19.0
nose: None
pip: 8.1.2
setuptools: 27.2.0
Cython: 0.24.1
numpy: 1.11.2
scipy: 0.18.1
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.7
blosc: None
bottleneck: 1.1.0
tables: 3.2.3.1
numexpr: 2.6.1
matplotlib: 1.5.3
openpyxl: 2.4.0
xlrd: None
xlwt: None
xlsxwriter: None
lxml: 3.6.4
bs4: 4.5.1
html5lib: 0.999
httplib2: 0.9.2
apiclient: 1.5.3
sqlalchemy: None
pymysql: None
psycopg2: 2.6.2 (dt dec pq3 ext lo64)
jinja2: 2.8
boto: 2.42.0
pandas_datareader: 0.2.1

@jorisvandenbossche
Copy link
Member

Note that this bug is inly present with lines=True (new feature in 0.19.0), with the default it works correctly:

In [50]: pd.DataFrame([{'a': 'foo}', 'b': 'bar'}, {'a': 'foo2', 'b': 'bar2'}]).to_json(orient='records')
Out[50]: '[{"a":"foo}","b":"bar"},{"a":"foo2","b":"bar2"}]'

@joshowen Thanks for the report!

cc @aterrel

@jorisvandenbossche jorisvandenbossche added Bug IO JSON read_json, to_json, json_normalize labels Oct 10, 2016
@jorisvandenbossche jorisvandenbossche added this to the 0.19.1 milestone Oct 10, 2016
tworec pushed a commit to RTBHOUSE/pandas that referenced this issue Oct 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO JSON read_json, to_json, json_normalize
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants