hhatto / hhatto/pyrapidjson

version 0.5.1, no exception but break the string line when dump some special data

Open
#22 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
25
Forks
5
PR merge metrics
No merged PRs in 30d

Description

when I use this lib to dumps some data, it make a puzzled question, [sample.log](https://github.com/hhatto/pyrapidjson/files/1634053/sample.log) is the minimized data to show it. my python version is 2.7.13 .

1. pyrapidjson 0.5 + not encode with utf-8
```
# -*- coding:utf-8 -*-
import codecs
import rapidjson
if __name__ == '__main__':
with codecs.open('sample.log', 'rb', 'utf-8') as f_read:
report_data = [f_read.read(),]
print report_data
report_json = rapidjson.dumps(report_data)
print report_json
```
it raise a crash about python like:

![image](https://user-images.githubusercontent.com/7637623/34978374-fc405cf4-fad8-11e7-98b2-b0b8c332aa8f.png)

2. pyrapidjson 0.5 + encode with utf-8
```
# -*- coding:utf-8 -*-
import codecs
import rapidjson
if __name__ == '__main__':
with codecs.open('sample.log', 'rb', 'utf-8') as f_read:
report_data = [f_read.read().encode('utf-8'),]
print report_data
report_json = rapidjson.dumps(report_data)
print report_json
```
it may right like:

![image](https://user-images.githubusercontent.com/7637623/34978470-4ce62ddc-fad9-11e7-9897-ba029edf0cde.png)

3. pyrapidjson 0.5.1 + not encode with utf-8
```
# -*- coding:utf-8 -*-
import codecs
import rapidjson
if __name__ == '__main__':
with codecs.open('sample.log', 'rb', 'utf-8') as f_read:
report_data = [f_read.read(),]
print report_data
report_json = rapidjson.dumps(report_data)
print report_json
```
it like the following picture, no exception but break the string line:

![image](https://user-images.githubusercontent.com/7637623/34978632-c8710260-fad9-11e7-9268-8466ea798d5e.png)

4. pyrapidjson 0.5.1 + encode with utf-8
```
# -*- coding:utf-8 -*-
import codecs
import rapidjson
if __name__ == '__main__':
with codecs.open('sample.log', 'rb', 'utf-8') as f_read:
report_data = [f_read.read().encode('utf-8'),]
print report_data
report_json = rapidjson.dumps(report_data)
print report_json
```
it like the following picture, also no exception but break the string line:

![image](https://user-images.githubusercontent.com/7637623/34978619-be02886c-fad9-11e7-9cdb-0cdfcb7cb997.png)

with this condition, I can't know right or not about dumps result. I think it may raise an exception when meet this condition or another way to let user know about this error.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.