我收到类似UTF-8编码的JSON文件
[
{
"FieldA": "regular string 1",
"FieldB": "... \ud83e\uddc0"
},
{
"FieldA": "regular string 2",
"FieldB": "... \ud83d\ude0d"
}
]
我尝试使用来阅读
df = pd.read_json(file_path, orient="columns", encoding="utf-8")
但是我看不到表情符号。有什么建议吗?
谢谢。
答案 0 :(得分:0)
您可以使用json
和json_normalize
:
import json
from pandas.io.json import json_normalize
j = [
{
"FieldA": "regular string 1",
"FieldB": "... \ud83e\uddc0"
},
{
"FieldA": "regular string 2",
"FieldB": "... \ud83d\ude0d"
}
]
s = json.dumps(j) # convert to string (serialize j to a json formatted string)
j2 = json.loads(s) # deserialize s to a python object
df = json_normalize(j2) # load to a dataframe
FieldA FieldB
0 regular string 1 ...
1 regular string 2 ...