草庐IT

unmarshall

全部标签

java - 远程异常 java.rmi.UnmarshalException : error unmarshalling return

这个问题在这里已经有了答案:java.rmi.ServerException:RemoteExceptionoccurredinserverthread(ClassNotFoundException)(5个答案)关闭5年前。我正在运行程序here在diff物理机上的2个JVM上。我得到错误RemoteExceptionjava.rmi.UnmarshalException:errorunmarshallingreturn;nestedexceptionis:java.lang.ClassNotFoundException:CalculatorImpl_Stub(nosecurityma

json - 当 json 输入结构错误时,Unmarshall 应该返回错误

我有结构A和B。当JSON字符串A被解码为结构A时它是有效的,但是如果JSON字符串A被解码为结构B它仍然是成功的(这不应该)。有什么方法可以检测到错误的JSON输入被错误地转换为错误的结构类型?请看下面的代码:playpackagemainimport("encoding/json""fmt")typeAstruct{Namestring`json:"name"`Ageint`json:"age"`}typeBstruct{Alamatstring`json:"alamat"`Umurint`json:"umur"`}funcmain(){varstructAAvarstructAA

json - 自定义时间 Marshall Unmarshall

我有一个MysqlTime结构,它有自己的编码和解码。typeMysqlTimestruct{time.Time}constMYSQL_TIME_FORMAT="2006-01-0215:04:05"func(t*MysqlTime)UnmarshalJSON(b[]byte)(errerror){s:=strings.Trim(string(b),`\`)ifs=="null"{t.Time=time.Time{}return}t.Time,err=time.Parse(MYSQL_TIME_FORMAT,s)return}func(t*MysqlTime)MarshalJSON()

go - yaml.v2 Unmarshaller 接口(interface)的有状态实现?

这可能是文件路径问题,也可能是关于如何最好地实现接口(interface)的问题。给定以下非常简单的yaml:name:MyYamlNamedata:some/relative/path.txt我想将它解码为以下结构:typeVerySimplestruct{namestringdataio.Reader}我已经在使用yaml.v2library,并且知道对于简单类型,我可以实现Unmarshaller界面。但是,在我的程序中,我不能假设一个绝对根,data字段中的相对路径基于该绝对根。有没有一种方法可以实现Unmarshaller接口(interface)来传递工作目录,或者可能有一

struct - MGO/GOLANG : Struct to unmarshall a document with

我有一个如下所示的Mongo模式:varphoneBookSchema=Schema({user_id:{type:Schema.Types.ObjectId,ref:'User',index:{unique:true},required:true},entries:{type:[entry],default:[]},matches:{type:[],default:[]}});条目文档数组如下所示:varentry=Schema({_id:false,phone:{type:String,index:true},name:{type:String},notified:{type:Bo

json - 不调用 Go json Unmarshaller

我对Golang还很陌生。我一直在寻找一种方法来为编码和解码json做一些自定义的事情。我找到了实现Marshaller和Unmarshaller接口(interface)的解决方案。这是我的struct实现接口(interface)(我也实现了Stringer):typeDatastruct{Foostring`json:"foo"`barstring}func(dData)MarshalJSON()([]byte,error){return[]byte("{\"foo\":\"test\",\"bar\":\"data\"}"),nil}func(dData)String()str

json - GoLang 中的 Marshall 和 UnMarshall JSON 内容

我有一个结构如下的示例json文件{"method":"brute_force","bc":"select*fromblah;","gc":["selectsum(year)fromblah;","selectcount(*)fromtable;"]}我正在尝试编写一个可以读取此文件并操作json内容的go程序。packagemainimport("fmt""encoding/json""io/ioutil")typeResponse2struct{methodstringbcstringgc[]string}funcmain(){file,_:=ioutil.ReadFile("co

android - 如何修复 Android 中偏移 YYY 处的 Unmarshalling unknown type code XXX?

由于Unmarshalling异常,我在恢复时遇到应用程序崩溃。我已经检查了所有可序列化的构造函数都没有参数,甚至使用ObjectStream检查了所有可序列化(保存到文件并从文件加载)。我如何理解导致异常的可分割偏移的实际类类型:Parcelandroid.os.Parcel@42209460:Unmarshallingunknowntypecode2131165303atoffset3748atandroid.app.ActivityThread.performLaunchActivity(ActivityThread.java:2080)atandroid.app.Activit

Java/JAXB : Unmarshall XML attributes to specific Java object attributes

有一个丑陋的XML文件需要解码:8081WARNING64Myes生成的Java对象应该是:publicclassDefaultOptions{privateintdefaultPort;privateStringlogLevel;//etc...}publicclassCustomOptions{privateStringmemory;privateStringcompatibility;//etc...}This问题的答案非常接近,但我无法弄清楚最终的解决方案。 最佳答案 怎么样?引入一个通用的父类(superclass),叫做