< em>{baseUrl}/products/1
Код: Выделить всё
{
"id": 1,
"name": "product1",
"type": "example",
"attributes": [
{
"attrib1": "text1",
"attrib2": "text2",
"attrib3": "text3",
},
{
"attrib1": "string1",
"attrib2": "string2",
"attrib3": "string2",
},
]
}
Код: Выделить всё
{
"products": [
{
"id": 1,
"name": "product1",
"type": "example",
"attributes": [
{
"attrib1": "text1",
"attrib2": "text2",
"attrib3": "text3"
},
{
"attrib1": "string1",
"attrib2": "string2",
"attrib3": "string3"
}
]
},
{
"id": 2,
"name": "product2",
"type": "example",
"attributes": [
{
"attrib1": "text1",
"attrib2": "text2",
"attrib3": "text3"
},
{
"attrib1": "string1",
"attrib2": "string2",
"attrib3": "string3"
},
{
"attrib1": "abc1",
"attrib2": "abc2",
"attrib3": "abc3"
}
]
},
{
"id": 3,
"name": "product3",
"type": "example",
"attributes": [
{
"attrib1": "text1",
"attrib2": "text2",
"attrib3": "text3"
}
]
}
]
}
Код: Выделить всё
DslPart product = newJsonBody((body) -> {
body.numberType("id", 1);
body.stringType("name", "product1");
body.stringType("type", "example");
body.array("attributes", (attributes) -> {
attributes.object((attrib) -> {
attrib.stringType("attrib1", "text1");
attrib.stringType("attrib2", "text2");
attrib.stringType("attrib3", "text3");
});
});
}).build();
Примерно так:
Код: Выделить всё
DslPart productList = newJsonBody((body) -> {
body.array("products", (products) -> {
products.object(product); // This is not possible, a LambdaDslObject is required
});
}).build();
Подробнее здесь: https://stackoverflow.com/questions/787 ... he-new-one