unmarshalling

Unmarshalling using JAXB

╄→гoц情女王★ 提交于 2019-12-11 10:56:43
问题 I am new to java (coming from c#.net background) and was trying the above example to marshal and unmarshal. Following the link below Marshalling a List of objects implementing a common interface, with JaxB using the above technique as mentioned by Mr.Blaise Doughan, I was able to marshal the java objects to xml. But when i save this xml and try to unmarshal the xml back to java object i get the following on the console: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2

Jaxb unmarshalls empty list with namespace [duplicate]

泪湿孤枕 提交于 2019-12-11 10:38:39
问题 This question already has an answer here : Issue with namespaces in XMLs in JAXB unmarshalling (1 answer) Closed 4 years ago . I have a simple xml to unmarshall. But I get only an empty list in the output. No exceptions are thrown. This is a third party generated xml and I need to make this work without any changes in the xml. The XML: <Animal xmlns="http://allmycats.com/serviceplatform/1.0/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Cat z:Id="i1" xmlns:z="http://schemas.microsoft

Difficulty with unmarshalling in parcelable

人走茶凉 提交于 2019-12-11 09:22:29
问题 Here is my code of writing to a parcel public void writeToParcel(Parcel dest, int flags) { dest.writeString(poiDescription); dest.writeString(latitude); dest.writeString(longitude); dest.writeString(placeName); dest.writeString(plistPath); dest.writeString(poiDirName); if (null != isMascotPresent) dest.writeString(isMascotPresent); if (null != startMascottTime) dest.writeInt(startMascottTime); if (null != mascottDuration) dest.writeInt(mascottDuration); } public PointOfInterest(Parcel source)

javax.xml.bind.UnmarshalException: Unexpected element. What am i missing?

≡放荡痞女 提交于 2019-12-11 07:51:52
问题 I am doing this, JAXBContext jaxbContext = JAXBContext.newInstance(new Class[] { mine.beans.ObjectFactory.class }); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); orderhistory = (OrderHistory) unmarshaller.unmarshal(new StreamSource( new StringReader(responseXML)));` I am getting javax.xml.bind.UnmarshalException: Unexpected element "OrderHistory". Expected elements are "{_http://orderhistory.shc.com/common/domain}OrderHistory". but i checked my OrderHistory.java i have the

Unmarshal dynamic YAML to map of structs

元气小坏坏 提交于 2019-12-11 07:01:49
问题 I'm trying to unmarshal the following YAML (using gopkg.in/yaml.v2): m: - unit: km formula: magnitude / 1000 testFixtures: - input: 1000 expected: 1 l: - unit: ml formula: magnitude * 1000 testFixtures: - input: 1 expected: 1000 With the following code: type ConversionTestFixture struct { Input float64 `yaml:"input"` Expected float64 `yaml:"expected"` } type conversionGroup struct { Unit string `yaml:"unit"` Formula string `yaml:"formula"` TestFixtures []ConversionTestFixture `yaml:

HyperLedger-Fabric ChainCode Deployment - Base64 error

安稳与你 提交于 2019-12-11 05:49:41
问题 I was trying to setup the Hyperledger blocchain on my laptop by following the Windows setup , was able to bring the docker images up and running, but when I try to deploy the examples provided, it always throws back the error in the JSON input as shown below. peer chaincode deploy -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Function":"init", "Args": ["a","100", "b", "200"]}' response: sug@sri-ub:~/go/$ docker exec -it aa413f4c4289 bash root@aa413f4c4289:

Problem unmarshalling an attribute with name “class” with Xstream

自古美人都是妖i 提交于 2019-12-11 04:57:11
问题 I have a node with an attribute named class . The input XML is : <Job class="com.test.jobImplementation"> <Priority>1</Priority> ...... </Job> The Java class which represents the XML is annotated with Xstream annotations is as follows: @XStreamAlias("Job") public static class Job { @XStreamAsAttribute @XStreamAlias("class") private String implementationClass; @XStreamAlias("Priority") private Integer priority } When I try to deserialize the XML, xstream fails returning an error unrelated to

Polymorphic JSON unmarshalling of embedded structs

僤鯓⒐⒋嵵緔 提交于 2019-12-11 04:44:57
问题 Here is an example (see also https://play.golang.org/p/or7z4Xc8tN): package main import ( "encoding/json" "fmt" ) type A struct { X string Y int } type B struct { A Y string } func main() { data := []byte(`{"X": "me", "Y": "hi"}`) b := &B{} json.Unmarshal(data, b) fmt.Println(b) fmt.Println(b.A) b = &B{} data = []byte(`{"X": "me", "Y": 123}`) json.Unmarshal(data, b) fmt.Println(b) fmt.Println(b.A) } Which outputs: &{{me 0} hi} {me 0} &{{me 0} } {me 0} Is there a way to polymorphically

How to preserve XML comments with JAXB?

泪湿孤枕 提交于 2019-12-11 04:39:34
问题 How to unmarshal and marshal a XML file without losing the comments? Is any way is there using JAXB, I tried example using following link but it doesn't work from me. <customer> <address> <!-- comments line 1 --> <street>1 Billing Street</street> </address> <address> <!-- comments line 2--> <street>2 Shipping Road</street> </address> </customer> I want to unmarshal the above xml, add a new address to it and marshall it back without losing the following the comments. <!-- comments line 1 --> <

JAXB hangs while unmarshaling socket stream

こ雲淡風輕ζ 提交于 2019-12-11 04:36:51
问题 Have an issue with marshall and unmarshall readers and writers. So here it is. This is how i marshall something to the PrintWriter. try { JAXBContext jaxbContext = JAXBContext.newInstance(XMLProtocol.class); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); //jaxbMarshaller.setProperty(, value) //jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); jaxbMarshaller.marshal(protocol, out); } catch (JAXBException e) { LOG.error("Error while processing protocol"+e); } This is how