Swift中的JSON和Node如何在GET请求中实现类别的过滤器

问题描述 投票:0回答:2

简单地说,我想将完整的json数组过滤为三类。

让我告诉你我在说什么

var menu = [
    {
        id: "coffe",
        name: "Espresso",
        description: "",
        image: ''
    },
    {
        id: "coffe",
        name: "Latte",
        description: "",
        image: ''
    },
    {
        id: "coffe-nosugar",
        name: "Hot Chocolate",
        description: "",
        image: ''
    },
{
        id: "tea",
        name: "Red Tea",
        description: " ",
        amount: "0.0",
        image: ''
    },
        {
        id: "tea",
        name: "Green Tea",
        description: " ",
        amount: "0.0",
        image: ''
    },
                {
        id: "fresh-juice",
        name: "Orange",
        description: "",
        amount: "0.0",
        image: ''
    }
]

现在,任何人都可以告诉我如何将这些数据分为三类

  • 咖啡
  • 果汁

现在我在我的nodeJS中使用它

app.get('/menu', (req, res) => res.json(menu))

要显示所有没有任何过滤器的库存项目,只需转到http://APIurl/menu即可

json node.js swift alamofire
2个回答
© www.soinside.com 2019 - 2024. All rights reserved.