【发布时间】:2021-04-21 19:12:09
【问题描述】:
我正在使用 json-server 来托管一个 json 文件,我可以使用 GET 获取整个文件,但我不知道如何访问 json 的特定嵌套部分。我以为 http://localhost:3004/data?program=Day%201 只会返回“第 1 天”,但我得到了整个文件。我该怎么办?
{
"data": {
"user": {"username": "Pedro", "id":1 },
"program":{
"Day 1" :[
{
"muscleGroup": "Chest",
"warmUp": ["parallel bar dips"],
"main": ["Bench Press", "Inclined Bench press", "Decline Bench press"],
"secondary": ["Dumbbell Flys", "Cable Crossover Flys", "Pec-deck Fly"]
},
{
"muscleGroup": "Biceps",
"main": ["Barbell Curl", "Preacher Curl"],
"secondary": ["Hammer Curls", "Cable Curl", "Dumbbell Curl"]
}
],
"Day 2" : [
{
"muscleGroup": "Shoulders",
"warmUp": ["parallel bar dips"],
"main": ["Bench Press", "Inclined Bench press", "Decline Bench press"],
"secondary": ["Dumbbell Flys", "Cable Crossover Flys", "Pec-deck Fly"]
},
{
"muscleGroup": "Abs",
"main": ["Crunch", "Leg raises"]
}
],
}
}
}
【问题讨论】:
标签: rest json-server