GAE with Python에서 urlfetch를 사용하여 Flickr에서 json 문자열을 가져옵니다. 프로덕션 서버에서 json.loads로 해당 문자열을로드하려고하면 "ValueError (Unpaired high surrogate) 발생"예외가 발생합니다.Python GAE : 프로덕션 서버에서만 json.loads로 ValueError (연결되지 않은 상위 대리) 발생
개발 콘솔에서 문자열을 json.loads하려고하면 예상대로 dict에로드됩니다 (아래 참조). Flickr에서 여러 개의 다른 json 문자열을 동일한 코드로 성공적으로로드했습니다. 아래 프로덕션 서버에서만 ValueError 예외를 throw하는 json 문자열에 대해 뭔가가 있습니다.
import json
s = """{"photo":{"id":"191019103", "secret":"d7a8bb95bc", "server":"72", "farm":1, "dateuploaded":"1153079847", "isfavorite":0, "license":"1", "safety_level":"0", "rotation":0, "originalsecret":"d7a8bb95bc", "originalformat":"jpg", "owner":{"nsid":"[email protected]", "username":"\ud800dc80 jgraham", "realname":"", "location":"", "iconserver":"38", "iconfarm":1}, "title":{"_content":"By the Year 2000 All Our Food Will be in the Form of Tiny Pills"}, "description":{"_content":""}, "visibility":{"ispublic":1, "isfriend":0, "isfamily":0}, "dates":{"posted":"1153079847", "taken":"2006-07-15 14:31:16", "takengranularity":"0", "lastupdate":"1282690106"}, "views":"984", "editability":{"cancomment":0, "canaddmeta":0}, "publiceditability":{"cancomment":1, "canaddmeta":0}, "usage":{"candownload":1, "canblog":0, "canprint":0, "canshare":1}, "comments":{"_content":"18"}, "notes":{"note":[]}, "people":{"haspeople":0}, "tags":{"tag":[{"id":"1207251-191019103-2909", "author":"[email protected]", "raw":"Birmingham", "_content":"birmingham", "machine_tag":0}, {"id":"1207251-191019103-77552", "author":"[email protected]", "raw":"Bullring", "_content":"bullring", "machine_tag":0}, {"id":"1207251-191019103-463", "author":"[email protected]", "raw":"Abstract", "_content":"abstract", "machine_tag":0}, {"id":"1207251-191019103-1174", "author":"[email protected]", "raw":"Architecture", "_content":"architecture", "machine_tag":0}, {"id":"1207251-191019103-141", "author":"[email protected]", "raw":"Blue", "_content":"blue", "machine_tag":0}, {"id":"1207251-191019103-2194948", "author":"[email protected]", "raw":"i500", "_content":"i500", "machine_tag":0}, {"id":"1207251-191019103-11820", "author":"[email protected]", "raw":"Explore", "_content":"explore", "machine_tag":0}, {"id":"1207251-191019103-3254511", "author":"[email protected]", "raw":"utata_feature", "_content":"utatafeature", "machine_tag":0}]}, "urls":{"url":[{"type":"photopage", "_content":"http:\/\/www.flickr.com\/photos\/jgraham\/191019103\/"}]}, "media":"photo"}, "stat":"ok"}"""
print json.loads(s) #prints dict
이것은 정말로 독특한 문제입니다! 'json.loads ('{ "username": "\\ ud800dc80 jgraham"}')'로 좁혔습니다. 나는 소스를 복사하고'json' 버전 2.0.9와 비교했으며 모든 의도와 목적이 동일하기 때문에이 오류는 다른 곳에서 발생합니다. 아직도 파고있어. – bossylobster
다음은 실패 이유에 대한 좋은 답변입니다. https://github.com/simplejson/simplejson/issues/62#issuecomment-13996448 – bossylobster