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: ujson labels are encoded twice #4593

Merged
merged 1 commit into from
Aug 21, 2013

Conversation

Komnomnomnom
Copy link
Contributor

With its current handling ujson ends up encoding labels twice, which can cause problems if they contain escapable characters:

In [16]: df = DataFrame([['a', 'b'], ['c', 'd']], index=['index " 1', 'index / 2'], columns=['a \\ b', 'y / z'])

In [17]: df
Out[17]: 
          a \ b y / z
index " 1     a     b
index / 2     c     d

In [18]: json = df.to_json()

In [19]: json
Out[19]: '{"a \\\\\\\\ b":{"index \\\\\\" 1":"a","index \\\\\\/ 2":"c"},"y \\\\\\/ z":{"index \\\\\\" 1":"b","index \\\\\\/ 2":"d"}}'

In [20]: pd.read_json(json)
Out[20]: 
           a \\ b y \/ z
index \" 1      a      b
index \/ 2      c      d

This PR fixes this behaviour so labels are only encoded a single time.

@jreback
Copy link
Contributor

jreback commented Aug 21, 2013

ok to merge?

@Komnomnomnom
Copy link
Contributor Author

Yep, fire away!

jreback added a commit that referenced this pull request Aug 21, 2013
BUG: ujson labels are encoded twice
@jreback jreback merged commit 3644370 into pandas-dev:master Aug 21, 2013
@Komnomnomnom Komnomnomnom deleted the ujson-slash-happy branch August 21, 2013 02:10
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

Successfully merging this pull request may close these issues.

None yet

2 participants