### Question:
SerializationUtils { public static void serializeSingleNamespaceJSONOutput(String namespaceURL, Object obj, OutputStream os) throws XMLStreamException, JAXBException { NamespaceConvention nsConv = NamespaceConvention.createSingleNamespaceSerializationConvention("ns1", namespaceURL); String rooJavaName = obj.getClass().getSimpleName(); QName rootXmlName = new QName(namespaceURL, rooJavaName); JSONStreamWriter sw = new JSONStreamWriter(nsConv, Charset.forName("UTF-8"), os); Class rootClass = obj.getClass(); JAXBContext jCtxt = JAXBContextBuilder.createJAXBContextForSerialization(rootClass); @SuppressWarnings("unchecked") JAXBElement jaxbElement = new JAXBElement(rootXmlName, rootClass, obj); Marshaller m = jCtxt.createMarshaller(); m.marshal(jaxbElement, sw); }  static void serializeSingleNamespaceJSONOutput(String namespaceURL, Object obj, OutputStream os); static void serializeSingleNamespaceNVOutput(String namespaceURL, Object obj, OutputStream os);  }### Answer:
@Test public void jaxbJSONSimpleSerialization() throws Exception { MyMessage msg = createTestMessage(1); ByteArrayOutputStream baos = new ByteArrayOutputStream(); SerializationUtils.serializeSingleNamespaceJSONOutput(TEST_NAMESPACE_URL, msg, baos); String result = baos.toString("UTF-8"); System.out.println(result); StringBuilder json = new StringBuilder(); json.append("{\"MyMessage\":["); json.append("{\"body\":[\""); json.append(new String(MESSAGE_BODY_TEXT)); json.append("\"],\"recipients\":"); json.append("[{\"entry\":[{\"key\":[\"soa0@ebayopensource.org\"],"); json.append("\"value\":[{\"city\":[\"San Jose\"],"); json.append("\"emailAddress\":[\"soa0@ebayopensource.org\"],"); json.append("\"postCode\":[\"95125\"],\"state\":[\"CA\"],"); json.append("\"streetNumber\":[\"2000\"]}]}]}]"); json.append(",\"something\":"); json.append("[{\"xsi.@type\":\"xs:string\","); json.append("\"__value__\":\"This is from the any object type\"}]"); json.append(",\"subject\":[\"SOA Framework test message\"]}"); json.append("]}"); assertEquals("JSON Form", result, json.toString()); }