Customer customer = new Customer();
customer.setCompanyName("Fancy Diddly");
// other setters
Marshaller marshaller;
marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, MediaType.APPLICATION_JSON);
marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, false);
marshaller.setProperty(MarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
//marshaller.setProperty(MarshallerProperties.JSON_, true);
marshaller.marshal(customer, System.out);
{
"registered_state_abbr" : "CA",
"state_registration_number" : "789",
"registration_status" : "Active",
"operation_type_id" : 1,
"fed_regulated" : "Yes",
"ein" : "12-34",
"company_name" : "Fancy Diddly",
"phone_no" : "916-123-5432"
}
[
{
"registered_state_abbr" : "CA",
"state_registration_number" : "789",
"registration_status" : "Active",
"operation_type_id" : 1,
"fed_regulated" : "Yes",
"ein" : "12-34",
"company_name" : "Fancy Diddly",
"phone_no" : "916-123-5432"
},
{
"registered_state_abbr" : "CA",
"state_registration_number" : "1337",
"registration_status" : "Active",
"operation_type_id" : 1,
"fed_regulated" : "Yes",
"ein" : "56-89",
"company_name" : "Bo Schmooh",
"phone_no" : "916-456-9876"
}
]
]]>