Problem is while reading back the same, derived elements are not recognized. Is there any way to manage derived elements and ignoreNamespace at the same time.
Thanks, Govind On Wed, May 9, 2012 at 2:46 PM, Sergey Beryozkin <[email protected]>wrote: > On 09/05/12 09:58, Govindaram PS wrote: > >> JsonProvider.writeTo fails to add xsitype when ignore namespace is set >> true. >> While reading the same it is failing to capture derived elements. >> >> > It does not make sense to include xsi:type when the namespaces are set to > be ignored > > Cheers, Sergey > > > >> Test case: >> >> @Test >> public void testWriteReadDerivedNoNs() throws Exception { >> JSONProvider<Base1> provider = new JSONProvider<Base1>(); >> provider.**setMarshallAsJaxbElement(true)**; >> provider.setIgnoreNamespaces(**true); >> provider.setWriteXsiType(true)**; >> >> Base1 b = new Derived1("base", "derived"); >> >> ByteArrayOutputStream bos = new ByteArrayOutputStream(); >> provider.writeTo(b, Base1.class, Base1.class, >> new Annotation[0], MediaType.APPLICATION_JSON_** >> TYPE, >> new MetadataMap<String, Object>(), bos); >> >> readBaseNoNs(bos.toString()); >> } >> >> private void readBaseNoNs(String data) throws Exception { >> JSONProvider<Base1> provider = new JSONProvider<Base1>(); >> provider.**setUnmarshallAsJaxbElement(**true); >> provider.setIgnoreNamespaces(**true); >> >> ByteArrayInputStream is = new ByteArrayInputStream(data.** >> getBytes()); >> >> Base1 base = provider.readFrom( >> Base1.class, Base1.class, >> new Annotation[0], MediaType.APPLICATION_JSON_** >> TYPE, >> new MetadataMap<String, String>(), is); >> assertEquals("base", base.getBase1Field()); >> Derived1 derived = (Derived1)base; >> } >> >> > > -- > Sergey Beryozkin > > Talend Community Coders > http://coders.talend.com/ > > Blog: http://sberyozkin.blogspot.com >
