classification
Title: strings in json.dump in '' instead of ""
Type: behavior Stage: resolved
Components: Library (Lib) Versions:
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: joru, petri.lehtinen, r.david.murray, refresh, terry.reedy
Priority: normal Keywords:

Created on 2010-08-24 12:25 by refresh, last changed 2012-08-28 10:06 by petri.lehtinen. This issue is now closed.

Messages (5)
msg114781 - (view) Author: refresh (refresh) Date: 2010-08-24 12:25
when you use json.dump() on object, the strings in the file it was written to are inside '' instead of ""
msg114782 - (view) Author: Jordan Szubert (joru) Date: 2010-08-24 12:40
could not reproduce:

Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from cStringIO import StringIO as F
>>> import json
>>> json.dumps('foo')
'"foo"'
>>> f=F()
>>> json.dump('foo',f)
>>> f.seek(0,0);f.read();f.seek(0,0)
'"foo"'
>>> json.dump({'a':['b']},f)
>>> f.seek(0,0);f.read();f.seek(0,0)
'{"a": ["b"]}'
>>> 


Python 2.6.5+ (release26-maint, Jul 30 2010, 23:04:10)
[GCC 4.4.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> from cStringIO import StringIO as F
>>> f=F()
>>> json.dump('foo',f)
>>> json.dumps('foo')
'"foo"'
>>> f.seek(0,0);f.read();f.seek(0,0)
'"foo"'
>>> json.dump({'a':1,'_':2},f)
>>> f.seek(0,0);f.read();f.seek(0,0)
'{"a": 1, "_": 2}'
>>> json.dumps({'a':1,'_':2})
'{"a": 1, "_": 2}'
>>>
msg114906 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-08-25 13:46
refresh, can you provide an example that shows the problem you are seeing?  Otherwise we'll close this.
msg115111 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-08-27 18:22
2.6.6 is the final 2.6 bugfix release. A bug would have to be demonstrated with 2.7 or 3.1/2. On 3.1, winxp, I get this also:
>>> import json
>>> json.dumps('foo')
'"foo"'
msg169264 - (view) Author: Petri Lehtinen (petri.lehtinen) * (Python committer) Date: 2012-08-28 10:06
No activity in 2 years, closing.
History
Date User Action Args
2012-08-28 10:06:02petri.lehtinensetstatus: pending -> closed
nosy: + petri.lehtinen
messages: + msg169264

2010-08-27 18:23:53terry.reedysetstatus: open -> pending
2010-08-27 18:23:43terry.reedysetstatus: pending -> open
nosy: terry.reedy, r.david.murray, refresh, joru
components: + Library (Lib), - None
2010-08-27 18:23:01terry.reedysetstatus: open -> pending
2010-08-27 18:22:50terry.reedysetstatus: pending -> open
versions: - Python 2.6
nosy: + terry.reedy

messages: + msg115111
2010-08-25 13:46:26r.david.murraysetstatus: open -> pending

nosy: + r.david.murray
messages: + msg114906

resolution: works for me
stage: resolved
2010-08-24 12:40:06jorusetnosy: + joru
messages: + msg114782
2010-08-24 12:25:33refreshcreate