-4

I'm looking for definition (structure) of object that can be converted to following JSON

 {
    "header":{
        "callbackUrl":"",
        "clientOrderId":"A565132",
        "clientOriginationId":"2345FE",
        "serviceProvider":"VERIZON",
        "transactionId":"EEDT44567"
    },
    "customer": {
        "nationalIdType":"",
        "nationalId":"",
        "addresses":[
            {
                "type":"WORK",
                "postalCode":"330066"
            }
        ],
        "serviceProviderAuthentication":[
            {
                "passcode":"",
                "securityQuestion":"",
                "securityAnswer":""
            }
        ]
    },
    "accountPhoneNumber":"",
    "accountNumber":""
}
Keegan
  • 11,345
  • 1
  • 25
  • 38
mbeider
  • 15
  • 4

1 Answers1

0

If you're looking for an example of how JsonBuilder would be used to create the JSON you've given, here it is

def json = new groovy.json.JsonBuilder()

json header: [
        callbackUrl:"",
        clientOrderId:"A565132",
        clientOriginationId:"2345FE",
        serviceProvider:"VERIZON",
        transactionId:"EEDT44567"
    ],
    customer:[
        nationalIdType:"",
        nationalId:"",
        addresses: [
            [
                type:"WORK",
                postalCode:"330066"
            ]
        ],
        serviceProviderAuthentication:[
            [
                passcode:"",
                securityQuestion:"",
                securityAnswer:""
            ]
        ]
    ],
    accountPhoneNumber:"",
    accountNumber:""

json.toString()

You might have been confused about how to create a JSON that doesn't have a root. The answer is: by passing a map.

Keegan
  • 11,345
  • 1
  • 25
  • 38
  • I looking for definition (structure) of object that can be converted to fallowing JSON – mbeider Jul 09 '15 at 19:28
  • I'm going to delete this answer since apparently it's not what you needed. Can you edit your question to explain in more detail what you need? If this isn't it, then I don't know what you're looking for. It sounds like you're looking for an object that something like Jackson would map to JSON, yet you tagged the question with jsonbuilder. – Keegan Jul 09 '15 at 19:33