Jquery从json获取数组并查看值是否存在

时间:2017-04-24 20:28:35

标签: javascript jquery json

我正在尝试编写一个使用jquery从JSON检索数据的脚本。我搜索了下载的数组。如何找到执行任何操作的值。 我使用getJSON提取数据,一切正常。但我找不到搜索。谁能帮我?来自JSON的数据:

[{"id":"10","data":"12345"},{"id":"11","data":"6666"}]

1 个答案:

答案 0 :(得分:0)

搜索数组的最简单方法是....

create procedure ProcedureName1 (
   @columnsname sysname --varchar(50) 
 , @columnsvalue varchar(50)
) as
begin
declare @sql nvarchar(max), @column_name sysname;
/* make sure the @columnsname is a valid column name */
set @column_name = (
  select c.name
  from sys.columns c
  where c.object_id = object_id(N'Tabl1') 
    and c.name = @columnsname
  );
set @sql = 'with cte as (
    select 
        ID
      , names
      , null as address
      , work
      , note
    from Tabl1
    where '+@column_name+' like @columnsvalue
    union all
    select 
        t2.ID
      , t2.name
      , t2.address
      , null
      , null as tt
    from Tabl2 as t2
    left join Tabl1 as t1 on t2.ID = t1.ID
    where '+@column_name+' like @columnsvalue
    )
  select *
  from cet
  order by 
      id
    , note desc
    , address;'
exec sp_executesql @sql, N'@columnsvalue varchar(50)', @columnsvalue
end;
go