我正在尝试设计一个可以与 Jersey 和 Jackson 一起使用的 JSON 对象。
我对 JSON / Restful 编程相当陌生,所以我想知道以下是否可行。
{
"name": "myservice",
"orders": [
{
"name": "iphone",
"description": "iPhone 5",
"providers": [
{
"name": "a",
"description": "AT&T",
"pricing": ["$40", "$70", "$120"]
},
{
"name": "b",
"description": "Verizon",
"pricing": ["$45", "$60", "$85"]
}
]
},
{
"name": "galaxy3",
"description": "Samsung Galaxy 3",
"providers": [
{
"name": "a",
"description": "AT&T",
"pricing": ["$45", "$60", "$85"]
}
]
}
]
}
获取有关 iPhone 的 Verizon 提供商的所有信息:
curl GET -H'Content-Type: application/json' https://mydomain/myservice/iphone/b
会返回:
{
"name": "b",
"description": "Verizon",
"pricing": ["$45", "$60", "$85"]
}
获取 iPhone 的 AT&T 提供商的定价列表:
curl GET -H'Content-Type: application/json' https://mydomain/myservice/iphone/a?pricing
将返回:
{
["$40", "$70", "$120"]
}
任何示例或反馈将不胜感激!