【发布时间】:2018-04-04 07:45:27
【问题描述】:
我在 Spring Boot 应用程序中使用 CrudRepository。它工作正常,但我得到了额外的 json 属性_links。我如何跳过那个额外的 json,因为它会影响渲染大型 json 对象。
我收到了这种json 格式的回复;
{
"_embedded": {
"userses": [
{
"user_name": "john doe",
"_links": {
"self": {
"href": "http://localhost:8080/userses/47375"
},
"users": {
"href": "http://localhost:8080/userses/47375"
}
}
},
{
"user_name": "john1 doe1",
"_links": {
"self": {
"href": "http://localhost:8080/userses/21665"
},
"users": {
"href": "http://localhost:8080/userses/21665"
}
}
},
{
"user_name": "remmya1 decruize1",
"_links": {
"self": {
"href": "http://localhost:8080/userses/47876"
},
"users": {
"href": "http://localhost:8080/userses/47876"
}
}
}
}
我如何忽略 json 中的额外部分。
【问题讨论】:
-
您能否提供更多信息,也许是一些代码?或者你想要什么而不是你得到什么的例子?看How do I ask a good question
-
@SBylemans 我已经用我得到的响应更新了这篇文章作为输出。我想这很好地解释了我的担忧。
-
stackoverflow.com/questions/23264044/… 也许这对您的情况会有所帮助。
-
您是如何使用
CrudRepository来实现此响应的?你将它映射到什么对象?通常CrudRepository被用作class MyObjectRepository implements CrudRepository<MyObject,Id> {...},其中 MyObject 是响应映射到的对象。
标签: java spring spring-mvc spring-boot crud