Filtering JSON data

后端 未结 8 551
暖寄归人
暖寄归人 2020-12-24 08:59

I have a JSON file which contains data like the following:

{\"posts\": [ 
    { \"title\":\"1\", \"url\":\"n1.png\" }, 
    { \"title\":\"2\", \"url\":\"n2.p         


        
8条回答
  •  一整个雨季
    2020-12-24 09:21

    I use Linq JS on my current project and it works really well for filtering data.

    http://jslinq.codeplex.com/

    var posts = [ 
        { "title":"1", "url":"n1.png" }, 
        { "title":"2", "url":"n2.png" }, 
        { "title":"3", "url":"n3.png" }, 
        { "title":"4", "url":"n4.png" }, 
        { "title":"5", "url":"n5.png" }, 
        { "title":"6", "url":"n6.png" }, 
        { "title":"7", "url":"n7.png" }, 
        { "title":"8", "url":"n8.png" }, 
        { "title":"9", "url":"n9.png" }, 
        { "title":"10", "url":"n10.png" }
    ];
    
    var filteredPost = JSLINQ(posts)
                       .Where(function(item){ return item.title >= "textBox1Value" && item.title <= "textBox2Value"; });
    

提交回复
热议问题