在使用python的json模块对json字串反序列化成python对象的时候出现的字符串都是unicode类型,而不是python内置的str类型.在某种使用场景下用户必须做显式的转换才能正常使用,徒增一些麻烦,为解决这一问题封装下述函数. def convert(input): if isinstance(input, dict): return {convert(key): convert(value) for key, value in input.iteritems()} elif i…
// // ViewController.swift // json读写 // // Created by mac on 15/7/14. // Copyright (c) 2015年 fangyuhao. All rights reserved. // import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any addition…
Python load json file with UTF-8 BOM header - Stack Overflow 3 down vote Since json.load(stream) uses json.loads(stream.read()) under the hood, it won't be that bad to write a small hepler function that lstrips the BOM: from codecs import BOM_UTF8 de…