问题标签 [simplejson]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - Python,将字典列出到 json
我有一个字典列表:
如何使用 simplejson 将 listDicts 转换为 json 字符串?使列表中的每个字典都将成为 JSON 中的一个对象。
python - SimpleJson 处理相同命名的实体
我在应用引擎中使用 Alchemy API,所以我使用 simplejson 库来解析响应。问题是响应的条目具有 sme 名称
所以问题是“subType”被重复了,所以负载返回的字典只是“TVActor”而不是一个列表。有没有办法解决这个问题?
python - 如何使用simplejson提取价值?
我有以下 json 字符串:
我怎样才能获得Something
价值?我执行以下操作
但它不起作用('list' object has no attribute 'get'
)
python - 如何使用 simplejson 正确解析 JSON?
我可以有以下 JSON 字符串:
或以下之一:
所以,我不确定是否所有的孩子和元素都在那里。进行以下验证是否足以获得Something
价值:
同样可以简化吗?
python - 无法使用简单的 json JSON 序列化 python Appengine GeoModel 子类
我正在开发一个简单的应用程序引擎应用程序,该应用程序利用地理搜索接近度获取。
我对数据进行了搜索和一些额外的过滤,一切顺利(我检查了返回结果的数量,结果和预期的一样)但是,当我尝试使用简单的 json 将它转储到 json 中时,我得到了以下错误:
TypeError: < backend.models.Listing object at 0x0570CC90 > is not JSON serializable
这是我在代码中定义对象的方式:
这就是我称之为邻近搜索的方法:
在尝试查找问题原因时,我尝试返回搜索中第一个结果的字典,当我这样做时,出现以下错误:
TypeError: datastore_types.GeoPt(23.0, 42.2) is not JSON serializable 这让我相信我处理地理点的方式有问题......
我尝试搜索这两个错误都没有结果,有什么线索吗?
PS,这是完整的堆栈跟踪:
文件“C:\Program >Files\Google\google_appengine\google\appengine\ext\appstats\recording.py”,第 897 行,在 >appstats_wsgi_wrapper 结果 = app(environ, appstats_start_response)
文件“C:\Users\roi.SEMANTV\PycharmProjects\gayville_tipfy\tipfy\app.py”,第 245 行,在 >dispatch rv = self.handle_exception(request, e)
文件“C:\Users\roi.SEMANTV\PycharmProjects\gayville_tipfy\tipfy\app.py”,第 241 行,在 >dispatch rv = self.router.dispatch(request)
文件“C:\Users\roi.SEMANTV\PycharmProjects\gayville_tipfy\tipfy\routing.py”,第 105 行,在 >dispatch rv = rv()
文件“C:\Users\roi.SEMANTV\PycharmProjects\gayville_tipfy\tipfy\handler.py”,第 297 行,在 > call response = self.dispatch()
文件“C:\Users\roi.SEMANTV\PycharmProjects\gayville_tipfy\tipfy\handler.py”,第 88 行,在 >dispatch return self.handle_exception(exception=e)
文件“C:\Users\roi.SEMANTV\PycharmProjects\gayville_tipfy\tipfy\handler.py”,第 86 行,在 >dispatch return self.make_response(method(**request.rule_args))
文件“C:\Users\roi.SEMANTV\PycharmProjects\gayville_tipfy\backend\handlers.py”,第 47 行,>在获取返回 json.dumps(结果)
文件“C:\Program >Files\Google\google_appengine\lib\django_0_96\django\utils\simplejson__init__.py”,行 >182,转储 **kw).encode(obj)
文件“C:\Program >Files\Google\google_appengine\lib\django_0_96\django\utils\simplejson\encoder.py”,行 >312,编码块 = list(self.iterencode(o))
文件“C:\Program >Files\Google\google_appengine\lib\django_0_96\django\utils\simplejson\encoder.py”,行 >262,在 _iterencode 中用于 self._iterencode_list(o,标记)中的块:
文件“C:\Program >Files\Google\google_appengine\lib\django_0_96\django\utils\simplejson\encoder.py”,行 >170,在 _iterencode_list 中用于 self._iterencode(值,标记)中的块:
文件“C:\
文件“C:\Program >Files\Google\google_appengine\lib\django_0_96\django\utils\simplejson\encoder.py”,第 279 行,在 _iterencode_default newobj = self.default(o)
文件“C:\Program >Files\Google\google_appengine\lib\django_0_96\django\utils\simplejson\encoder.py”,行 >300,默认提高 TypeError("%r is not JSON serializable" % (o,) )
json - SVG serialization
I have RaphaelJS based canvas, where user can do some work. I need to do 2 things:
- Save users work into database
- Rastersize SVG (I use Apache Batik for that task)
For 1 https://github.com/jspies/raphael.serialize dumps Raphael's canvas to json, then jQuery.getJSON() to send it to the backend, where I need to convert it back to SVG to feed into Batik.
Does this flow seem reasonable? SVG -> JSON -> SVG conversion seems a bit overhead, is there a better way to do this?
Backend runs python/django. I use standard json package for JSON -> SVG, but sometimes it fails with syntax errors in the incoming json (mainly in font style properties). Did anyone face these issues?
What's the best way to store this data in the database? Just as a string?
jquery - simplejson double escapes data causing invalid JSON string
I have a simple form for managing manufacturers in my shop. After posting form, ajax call returns json with updated data to the form. Problem is, that the returned string is invalid. It looks like it was double-escaped. Strangely similar approach across the whole shop works without any problems. I'm also using jquery 1.6 as javascript framework.
Model contains of 3 fields : char for name, text for description and image field for manufacturer logo.
The function :
The error in console : error with invalid JSON :
uncaught exception: Invalid JSON: {"html": [["#data", "\n<h2>Dane</h2>\n<div class="\"manufacturer-image\"">\n \n</div>\n<form action="\"/manage/update-manufacturer-data/1\"" method="\"post\"">\n \n <div class="\"field\"">\n <div class="\"label\"">\n <label for="\"id_name\"">Nazwa</label>:\n </div>\n \n \n <div class="\"error\"">\n <input id="\"id_name\"" name="\"name\"" maxlength="\"50\"" type="\"text\"">\n <ul class="\"errorlist\""><li>Pole wymagane</li></ul>\n </div>\n \n </div>\n\n <div class="\"field\"">\n <div class="\"label\"">\n <label for="\"id_image\"">Zdjecie</label>:\n </div>\n \n \n <div>\n <input name="\"image\"" id="\"id_image\"" type="\"file\"">\n </div>\n \n </div>\n\n <div class="\"field\"">\n <div class="\"label\"">\n <label for="\"id_description\"">Opis</label>:\n </div>\n \n \n <div>\n <textarea id="\"id_description\"" rows="\"10\"" cols="\"40\"" name="\"description\""></textarea>\n </div>\n \n </div>\n \n <div class="\"buttons\"">\n <input class="\"ajax-save-button" button\"="" type="\"submit\"">\n </div>\n</form>"], ["#selectable-factories-inline", "\n <div>\n <a class="\"selectable" selected\"\n="" href="%5C%22/manage/manufacturer/1%5C%22">\n L1\n </a>\n </div>\n\n <div>\n <a class="\"selectable" \"\n="" href="%5C%22/manage/manufacturer/4%5C%22">\n KR3W\n </a>\n </div>\n\n <div>\n <a class="\"selectable" \"\n="" href="%5C%22/manage/manufacturer/3%5C%22">\n L1TA\n </a>\n </div>\n\n"]]}
Any ideas ?
python - App Engine 上的 Python 2.7,simplejson 与原生 json,谁更快?
我的理解是 simplejson 比 Python 中的原生 json 快得多,例如这个线程: What are the difference between json and simplejson Python modules?
但是,当我在使用 Python 2.7 的 App Engines 文档中阅读时,我只是陷入了一个循环
使用原生 JSON 库,比 simplejson 快得多。
http://code.google.com/appengine/docs/python/python27/newin27.html
所以现在我很困惑。其他地方似乎都说 simplejson 更好,但现在使用 Python 2.7 的 App Engine 说本机更快。是什么赋予了?
python - 如何在win7 64位上为python 2.5安装simplejson
当我尝试在运行 Win7 64 位的机器上安装适用于 Python 2.5(64 位发行版)的 simplejson 时,出现此错误:
AttributeError:MSVCCompiler 实例没有属性“_ MSVCCompiler__root”
我正在使用 pip 并且还安装了 Python 2.7 64 位,并且能够为 Python 2.7 安装 simplejson。
谁能告诉我我需要做些什么来解决这个问题?
谢谢,
python - 用python从ustream api解码json
我正在尝试使用 simplejson 来解析来自 ustream 数据 api 的请求,并且在解码时出现此错误。我是 python 中 json 库的新手,所以我不确定从哪里开始寻找解决方案。
有什么帮助吗?