如何获得JSON数组的长度?(How to get the length of JSON array?)
我有一个与以下类型的响应json网址
[ { "gender": "Female", "age": 7, "class": 2, "subject": [ "", "", "" ] }, { "gender": "Female", "age": 8, "class": 3, "subject": [ "ab", "cd", "ef" ] }, ... ]
我想找到这个数组的长度
所以在我使用的角度应用程序
export class CustomComponent implements OnInit { length: number; constructor() { this.length = Object.keys('www.url...').length; console.log(length); }
在.html中我有
<p>{{ length }}</p>
我得到61,而实际的长度是44,但另一方面控制台显示0。
我哪里错了?
任何形式的帮助将不胜感激。 谢谢。
I have a json url with a response of the following kind
[ { "gender": "Female", "age": 7, "class": 2, "subject": [ "", "", "" ] }, { "gender": "Female", "age": 8, "class": 3, "subject": [ "ab", "cd", "ef" ] }, ... ]
I want to find the length of this array
so in the angular app I am using
export class CustomComponent implements OnInit { length: number; constructor() { this.length = Object.keys('www.url...').length; console.log(length); }
in .html I have
<p>{{ length }}</p>
I am getting 61 whereas the actual length is 44, but the console on the other hand is showing 0.
Where am I going wrong?
Any kind of help would be greatly appreciated. Thanks.
原文:https://stackoverflow.com/questions/49105886
最满意答案
你试过下面的查询吗?
SELECT p.sent,e。*,e.no _id from ecare e LEFT JOIN pweb p ON e.h_id = p.h_id WHERE(ant ='N'或ant ='D')AND p.sent ='0' GROUP BY e.h_id
Have you tried with below query ?
SELECT p.sent,e.*, e.no _id from ecare e LEFT JOIN pweb p ON e.h_id=p.h_id WHERE (ant = 'N' or ant = 'D') AND p.sent = '0' GROUP BY e.h_id
相关问答
更多-
在DataBaseHelper中编写您的方法,就像这样 public ArrayList
getUsersList() { ArrayList userList = null; Cursor cursor = null; try { String queryString = "SELECT _id , name, address, type FROM User"; cursor = ... -
将这些信息存储在两个不同的数据库中的概念听起来不对,但如果您需要从两者中获取数据,则必须执行UNION ALL : SELECT x.col1, x.col2 FROM ( SELECT a.col1, b.col1 FROM db1.a JOIN db1.b ON ( ... ) UNION ALL SELECT a.col1, b.col1 FROM db2.a JOIN db2.b ON ( ... ) ) x WHERE x.col1 = ... ...
-
使用GROUP_CONCAT : SELECT P.product_id, GROUP_CONCAT(PC.category_id SEPARATOR ', ') FROM Product_Category PC , Products P WHERE PC.product_id = P.product_id GROUP BY P.product_id; 看看这个小提琴 。 Use GROUP_CONCAT for this: SELECT P.product_id, ...
-
如何从数据库中获取数据?(how to fetch data from database?)[2021-04-10]
它取决于您使用的Silverlight版本。 无论如何,网上有一些非常好的和全面的教程。 以下是一些有趣的内容: http://silverlight.net/learn/tutorials/sqldatagrid.aspx http://www.simple-talk.com/dotnet/.net-framework/data-and-silverlight-2-data-binding/ It depends a little on the version of Silverlight that yo ... -
订购后使用LIMIT获得前3名,如下: SELECT * FROM myTable ORDER BY salary DESC LIMIT 3; Use LIMIT to get top 3 after ordering, as such: SELECT * FROM myTable ORDER BY salary DESC LIMIT 3;
-
查询从数据库中获取数据(Query to Fetch Data from Database)[2023-03-09]
你试过下面的查询吗? SELECT p.sent,e。*,e.no _id from ecare e LEFT JOIN pweb p ON e.h_id = p.h_id WHERE(ant ='N'或ant ='D')AND p.sent ='0' GROUP BY e.h_id Have you tried with below query ? SELECT p.sent,e.*, e.no _id from ecare e LEFT JOIN pweb p ON e.h_id=p.h_id WHER ... -
SELECT i.id, i.EMAIL_ID, wmsys.wm_concat(cun.NAME||': '||cuv.VALUE) fields_and_values FROM lmss_user i join CUSTOM_FIELD_NAME cun on cun.user_id = i.id join CUSTOM_FIELD_VALUE cuv on cuv.user_id = i.id and cuv.field_name_id = cun.id group by i ...
-
使用TO_CHAR函数格式化DATETIME列,因此您可以将GROUP BY用于聚合函数: SELECT TO_CHAR(t.time, 'YYYY-MM-DD HH24') AS hourly, COUNT(*) AS numPerHour FROM YOUR_TABLE t GROUP BY TO_CHAR(t.time, 'YYYY-MM-DD HH24') Use the TO_CHAR function to format the DATETIME column, ...
-
Android数据库提取查询(Android database fetch query)[2023-07-12]
试试这....获取数据 public Cursor FunctionName(String category) { Cursor mCursor = ourDatabase .query(true, DATABASE_TABLE_NAME, new String[] { CATEGORY_ID, CATEGORY_NAME, CATEGORY_IMAGE }, CATEGORY_IMAGE + ... -
无法从数据库中获取数据(Cannot Fetch a Data From Database)[2023-11-08]
您正在移动光标位置两次。 只需删除行cursor.moveToFirst(); moveToNext方法足以在第一次迭代时移动到第一个位置。 I feel like a idiot because i forgot to type the database name at the constructor method like that: Old super(context, null, null, 1); Now super(context, "database", null, 1); Thanks ...