unmarshalling

Grails Date unmarshalling

青春壹個敷衍的年華 提交于 2019-11-27 07:41:26
If I get the following json from a RESTful client, how do I elegantly unmarshal the java.util.Date? (Is it possible without providing (aka. hard-coding) the format, that's what I mean by elegantly...) { "class": "url", "link": "http://www.empa.ch", "rating": 5, "lastcrawl" : "2009-06-04 16:53:26.706 CEST", "checksum" : "837261836712xxxkfjhds", } The cleanest way is probably to register a custom DataBinder for possible date formats. import java.beans.PropertyEditorSupport; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util

Parcel Unmarshalling unknown type code

三世轮回 提交于 2019-11-27 04:25:33
问题 We are getting this error in the Crash reports logged by play store. Cant replicate this in all our testing. Does anyone else have the same problem or solution ? Thing is, we dont even know what to do to replicate this bug. All Parcelable objects have CREATOR, writeToParcel() and contructor defined. All Lists and complex types are initialised and null checked. java.lang.RuntimeException: Unable to start activity ComponentInfo{au.com.company/au.com.company.DetailsActivity}: java.lang

How to fix Unmarshalling unknown type code XXX at offset YYY in Android?

假装没事ソ 提交于 2019-11-27 04:24:58
问题 I'm having app crash on resume because of Unmarshalling exception. I've checked all the Serializables have constructor with no parameters and even checked all the serializables using ObjectStream (save to file and load from file). How can i understand actual class type for parcelable offset that cause exception: Parcel android.os.Parcel@42209460: Unmarshalling unknown type code 2131165303 at offset 3748 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2080) at android

How to make JAXB unmarshaller to ignore prefixes?

删除回忆录丶 提交于 2019-11-26 23:24:45
问题 I have the following XML: <ns2:Person name="John" age="20" /> And I want to unmarshal it to JAXB object Person which was generated from the XSD. this is the code I'm running: JAXBContext context = JAXBContext.newInstance(PersoEntity.class); Unmarshaller um = context.createUnmarshaller(); StringReader sr = new StringReader(xml); Person p = (Person)um.unmarshal(sr); Surprisingly I get the following exception: javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax

Decoding generic JSON objects to one of many formats

余生长醉 提交于 2019-11-26 20:46:44
问题 I am working on a general JSON based message passing protocol in Go. What I would like to do is have a BaseMessage that has general information like Type , timestamp , etc. But at the same time I want to be able to define more specific message structures for certain types of data. For example: type Message struct { Type string `json:type` Timestamp string `json:timestamp` } type EventMessage struct { Message EventType string EventCreator string EventData interface{} } I have a set of handlers

“BadParcelableException: ClassNotFoundException when unmarshalling <myclass>” while using Parcel.read method that has a ClassLoader as argument

混江龙づ霸主 提交于 2019-11-26 18:00:03
问题 Given a custom class org.example.app.MyClass implements Parcelable , I want to write a List<MyClass> to a Parcel. I did the marshalling with List<MyClass> myclassList = ... parcel.writeList(myclassList); whenever I try to unmarshall the class with List<MyClass> myclassList = new ArrayList<MyClass>(); parcel.readList(myclassList, null); there is an "BadParcelableException: ClassNotFoundException when unmarshalling org.example.app.MyClass" exception. What is wrong here? Why is the class not

JAXB - Ignore element

无人久伴 提交于 2019-11-26 16:59:46
问题 Is there any way to just ignore an element from Jaxb parsing? I have a large XML file, and if I could ignore one of the large, complex elements, then it would probably parse a lot quicker. It would be even better if it could not even validate the element contents at all and parse the rest of the document even if that element is not correct. ex:this should only generate Foo.element1 and Foo.element2 <foo> <element1>I want this</element1> <element2>And this</element2> <bar> <a>ALL of bar should

How can I have JAXB call a method after it has completed unmarshalling an XML file into an object?

旧城冷巷雨未停 提交于 2019-11-26 16:34:13
问题 I am using JAXB to unmarshall an XML file into a Java object -- standard stuff. Once JAXB has completed this, I'd like a method to be called on the newly created object. Is there a mechanism to do this? I'd prefer the object, not an external entity, do this to keep construction in one place. Thanks. 回答1: To be able to execute code after unmarshalling took place, you need an Unmarshaller-Listener However, I'm not sure, if the listener is invoked after the properties are set or before. NOTE:

Grails Date unmarshalling

ぐ巨炮叔叔 提交于 2019-11-26 13:46:04
问题 If I get the following json from a RESTful client, how do I elegantly unmarshal the java.util.Date? (Is it possible without providing (aka. hard-coding) the format, that's what I mean by elegantly...) { "class": "url", "link": "http://www.empa.ch", "rating": 5, "lastcrawl" : "2009-06-04 16:53:26.706 CEST", "checksum" : "837261836712xxxkfjhds", } 回答1: The cleanest way is probably to register a custom DataBinder for possible date formats. import java.beans.PropertyEditorSupport; import java

Android E/Parcel﹕ Class not found when unmarshalling (only on Samsung Tab3)

a 夏天 提交于 2019-11-26 12:24:43
问题 I\'ve been unable to resolve why this error occurs, and only on a Samsung Tab3 device, running 4.4.2? It happens when my MainActivity starts another Activity, and passes a Parcelable class in the intent like so: private void debugTest(TestParcel cfgOptions){ TestParcel cfgOptions = new TestParcel(); cfgOptions.setValue(15); //just to verify Intent intent = new Intent(MainActivity.this, TestActivity.class); intent.putExtra(\"cfgOptions\", cfgOptions); startActivityForResult(intent, DBG_TEST);