Skip to content

to_json on multiindex does not escape strings properly #15273

Closed
@rs2

Description

@rs2

Code Sample, a copy-pastable example if possible

import pandas as pd
import datetime

pd.read_json(pd.DataFrame(True, index=pd.date_range(datetime.date(2017, 1, 20), datetime.date(2017, 1, 23)), columns=['foo', 'bar']).stack().to_json())

Problem description

The result of pd.DataFrame(True, index=pd.date_range(datetime.date(2017, 1, 20), datetime.date(2017, 1, 23)), columns=['foo', 'bar']).stack().to_json() contains

r'{"[1484870400000,"foo"]":true,"[1484870400000,"bar"]"',

Expected Output

Whereas it should be:
r'{"[1484870400000,\"foo\"]":true,"[1484870400000,\"bar\"]"'

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.4.5.final.0 python-bits: 32 OS: Windows machine: AMD64 LC_ALL: None LANG: None LOCALE: None.None

pandas: 0.19.1
Cython: 0.25.1
numpy: 1.11.2
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions