TIM*_*MEX 4 javascript string jquery parsing json
Uncaught TypeError: Converting circular structure to JSON
Run Code Online (Sandbox Code Playgroud)
我正在尝试stringify的对象是这个(我在javascript控制台中记录):
Object
GsearchResultClass: "GlocalSearch"
accuracy: "8"
addressLines: Array[2]
city: "Cupertino"
content: ""
country: "United States"
ddUrl: "http://www.google.com/maps?source=uds&daddr=10825+North+Wolfe+Road,+Cupertino,+CA+(Southland+Flavor+…"
ddUrlFromHere: "http://www.google.com/maps?source=uds&saddr=10825+North+Wolfe+Road,+Cupertino,+CA+(Southland+Flavor+…"
ddUrlToHere: "http://www.google.com/maps?source=uds&daddr=10825+North+Wolfe+Road,+Cupertino,+CA+(Southland+Flavor+…"
html: HTMLDivElement
lat: "37.335405"
listingType: "local"
lng: "-122.015386"
maxAge: 604800
phoneNumbers: Array[1]
region: "CA"
staticMapUrl: "http://maps.google.com/maps/api/staticmap?maptype=roadmap&format=gif&sensor=false&size=150x100&zoom=…"
streetAddress: "10825 North Wolfe Road"
title: "Southland Flavor Cafe"
titleNoFormatting: "Southland Flavor Cafe"
url: "http://www.google.com/maps/place?source=uds&q=stinky&cid=9384294304761453216"
viewportmode: "computed"
__proto__: Object
Run Code Online (Sandbox Code Playgroud)
而我这样做:
JSON.stringify(theobject);
Run Code Online (Sandbox Code Playgroud)
一个对象在某处引用自己; 因此消息"循环结构".我怀疑它可能在HTMLDivElement.您是仅将此用于调试目的还是实际上想要使用此JSON做一些有意义的事情?如果您只是将它用于调试,那么大多数现代JavaScript调试器都会让您将对象记录到控制台.如果您实际上正在尝试对数据执行某些操作,则应该只从该对象中提取所需的内容并将它们放入可以传递给的新的剪裁对象中JSON.stringify.该对象看起来像是来自Google API并且其中包含大量额外数据.
如果您不介意破坏性地修改对象,请尝试选择性地清空可疑字段并查看JSON.stringify是否接受该对象.至少那样你就会知道是什么导致了它.请注意,如果您这样做,您最终可能会破坏该对象以供将来使用.
| 归档时间: |
|
| 查看次数: |
10873 次 |
| 最近记录: |