0
클래스 구독자 (상위)와 하위 옵션 (하위)이 있습니다. 그들은 일대일 관계가 있습니다.JSON Marshaller가 표시 할 속성을 지정합니다.
클래스 가입자 {
String picture
String versionn
String title
String subtitle
Integer guid
Integer saleprice
Integer msrp
Integer costprice
String saletype
String category
String storecategory
String brand
String condition
String shipwithin
String modelskucode
String state
String link
String image
String image2
String image3
String image4
String description
String publishdate
Integer active
Integer weight
Integer quantity
String shippingprice
String whopay
String shiptolocation
String shippingmethod
String paymentmethod
String gsttype
String optionsstatus
Options options
Optionsdetails optionsdetails
아래 클래스 인 반면 Optiondetails
class Optionsdetails {
String sku
String usersku
Integer price
Integer saleprice
Integer msrp
Integer costprice
Integer quantity
Integer warningqty
String image1
Integer status
static belongTo = [subscriber: Subscriber]
나는 이러한 클래스에서 특정 속성을 렌더링 할, 그래서 다음과 같이 부트 스트랩에 코드를했다
class BootStrap {
def init = { servletContext ->
JSON.registerObjectMarshaller(Subscriber) {
def returnArray = [:]
returnArray['title'] = it.title
returnArray['Id'] = it.guid
returnArray['description'] = it.description
returnArray['saletype'] = it.saletype
returnArray['options'] = ["optionName1": it.options.optionName1, "optionDetail1": it.options.optionDetail1]
returnArray['optionsdetails'] = it.optionsdetails.list()
return returnArray
}
}
클래스 구독자 속성에는 문제가 없지만 볼 대상에 맞게 사용자 정의 할 수있는 방법은 무엇입니까? 또는 Optionsdetails 클래스의 속성 예를 들어 ID를 표시하고 싶지 않고 표시된 속성을 정렬하려고합니다. 아래는 JSON 모양입니다
[
{
"title": "Female bag 2017 spring and summer new ladies shoulder bag wild shell small bag handbag female bag Messenger bag",
"Id": 710,
"description": "<font style=\"vertical-align: inherit;\"><font style=\"vertical-align: inherit;\">loading description...</font></font>",
"saletype": "B",
"options": {
"optionName1": "Color",
"optionDetail1": "Navy blue,light Grey,Taro purple,Deep purple,Dark gray,Pink,Light blue,Dark pink,black,Red wine,"
},
"optionsdetails": [
{
"id": 1,
"costprice": null,
"image1": "710.0",
"msrp": null,
"price": null,
"quantity": 4561,
"saleprice": null,
"sku": "Navy blue",
"status": 1,
"usersku": null,
"warningqty": 0
},
{
"id": 2,
"costprice": null,
"image1": "710.0",
"msrp": null,
"price": null,
"quantity": 4331,
"saleprice": null,
"sku": "light Grey",
"status": 1,
"usersku": null,
"warningqty": 0
},
친절하게 안내하십시오. 감사합니다