Json数据转换为javascript数组(Json data into javascript array)
var test=[]; $(document).ready(function(){ $.getJSON("data.json",function(data){ $.each(data,function(key,value){ test.push(value.topic); }); }); });
这是我的javacript代码。 我想用键作为主题推送json对象的所有值。 但是当我尝试访问test [i](我是数组长度内的任何整数)时,出现“undefined”错误。 我有什么困难?
这是我的json对象sample-
[ { "topic": "Books", "quantity": 3 }, { "topic": "Grossery", "quantity": 3 }, { "topic": "stationery", "quantity": 3 }, { "topic": "food", "quantity": 2 }, { "topic": "market items", "quantity": 3 } ]
var test=[]; $(document).ready(function(){ $.getJSON("data.json",function(data){ $.each(data,function(key,value){ test.push(value.topic); }); }); });
Here is my javacript code. I want to push json object's all values with key as topic. But when I try to access test[i] (i be any integer within array length) I get an error "undefined" . What' am I msissing?
Here is my json object sample-
[ { "topic": "Books", "quantity": 3 }, { "topic": "Grossery", "quantity": 3 }, { "topic": "stationery", "quantity": 3 }, { "topic": "food", "quantity": 2 }, { "topic": "market items", "quantity": 3 } ]
原文:https://stackoverflow.com/questions/50134338
最满意答案
在DB(而不是
Text
)中将description
字段定义为Memo
,然后从ADOQuery1
删除所有持久字段,然后再次添加它们,以便ADOQuery1codemeaning_description
类型为ftMemo
。无需逃跑或取代
CRLF
。Define your
description
field asMemo
in the DB (instead ofText
), and then remove all your persistent fields fromADOQuery1
, and add them again so thatADOQuery1codemeaning_description
type isftMemo
.No need to escape or replace
CRLF
.
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
有可能使用内置到Access中的Jet复制,但我会警告你,它非常脆弱。 它也会在你做任何表的时候搞乱你的PK,因为它会选择随机签名整数来避免重要冲突,所以你最终可能会以-1243482392912作为你在给定记录上的下一个PK。 如果你正在做任何类型的查询(如客户ID,订单号等),那么这是一个PITA。你不能自动化Access同步(也许你可以通过使用VBA来伪造类似的东西,但仍然,只有在打开数据库时才会运行)。 我建议的方法是在您的“中央”数据库上使用SQL Server 2005/2008,并在您的“远程 ...
-
镜像MS Access数据库(Mirroring MS Access Database)[2022-10-01]
我最近遇到了类似的问题,我解决这个问题的方法是在PowerPivot(64位)中构建主数据库 - 这是一个免费的Excel加载项,可轻松连接到Access和Excel。 随着在其他数据库中添加或更改更多数据,PowerPivot(64位)引擎非常快速将自动处理数据刷新。 希望这可以帮助。 I had a similar problem recently and the way I solved this was to build the master database in PowerPivot(64bit ... -
如何从TMemo组件添加多行到MS Access数据库?(How to add multiple lines from a TMemo component to a MS Access database?)[2023-07-03]
在DB(而不是Text )中将description字段定义为Memo ,然后从ADOQuery1删除所有持久字段,然后再次添加它们,以便ADOQuery1codemeaning_description类型为ftMemo 。 无需逃跑或取代CRLF 。 Define your description field as Memo in the DB (instead of Text), and then remove all your persistent fields from ADOQuery1, and ... -
Delphi中的TMemo滚动(TMemo Scrolling in Delphi)[2022-11-12]
您可以使用线条集合的开始/结束更新: memo.Lines.BeginUpdate; try memo.Lines.Add('test'); finally memo.Lines.EndUpdate; end; You can use begin/end update for lines collection: memo.Lines.BeginUpdate; try memo.Lines.Add('test'); finally memo.Lines.EndUpdate; end; -
这常常被误引和误解。 这里的建议也是正确的。 因此,所谓的JET数据库引擎已经成为Windows的一部分,并作为默认安装组件预先安装了10多年。 实际上它是Windows 98SE的默认值。 这意味着一个全新的开箱即用的Windows机器可能没有安装软件使用像Windows脚本这样的东西可以打开这些Access文件。 所以你可以从VB.net,c#等打开这些文件,而无需任何额外安装的组件。 但请记住,自2007年以来,如果使用新的accDB格式文件而不是mdb,则必须安装较新版本的JET引擎。 此较新版本的 ...
-
只需从我的网站添加一些页面到这个讨论。 您想要将MDB拆分为包含查询,表单,报表,宏和模块的前端MDB,只需在后端MDB中包含表和关系。 FE被复制到每个网络用户计算机。 FE MDB链接到驻留在服务器上的后端MDB中的表。 您可以更新FE MDB并将其分发给用户,可能是MDE。 有关更多信息,请参阅“将应用程序分成前端和后端提示”页面。 请参阅免费的Auto FE更新程序实用程序,以使新FE的分发相对简单。该实用程序还非常好地支持终端服务器/ Citrix。 另请访问我的Access Performanc ...
-
如何在ms访问中从数据库的jcombobox中添加多个项目(How do I add multiple items from a jcombobox from a database in ms access)[2023-01-15]
不要使用null布局和setBounds(...)。 Swing旨在与布局管理器一起使用。 不需要comboBox.setVisible(true)因为默认情况下Swing组件(顶级容器除外)是可见的。 为什么它总是抱怨并建议抑制警告? 您尚未指定将添加到组合框模型的数据类型。 您正在添加字符串数据,因此您应该使用: JComboBoxcombo = new JComboBox (); 阅读泛型 ,了解更多信息。 如何从数据库中允许多个项目在jcombobox中? 你没有做 ... -
您必须将ScrollBars属性设置为ssHorizontal,ssVertical或ssBoth ,并将IMouse单元添加到您的项目中。 UPDATE 为避免IMouse单元导致的内存泄漏,必须在应用程序退出之前添加此代码(例如,在主单元的finalization部分中)。 if Assigned(Mouse.PanningWindow) then Mouse.PanningWindow := nil; You must set the ScrollBars property to ssH ...