FAQ Database Discussion Community


struct pointer and fixed char

c#,c++,dll,struct,unmarshalling
i have a structure in my C++ like this struct ST_HDTextInfo { char* font_name; char* text; unsigned int font_color; unsigned int background_color; int style; int font_size; struct ST_HDTextInfo* next; }; and i redeclare it in my C# code like this [StructLayout(LayoutKind.Sequential,Pack=4)] unsafe struct ST_HDTextInfo { [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 25)] public...

json.Unmarshal returning blank structure

json,go,unmarshalling
I have a JSON blob that looks like this { "metadata":{ "id":"2377f625-619b-4e20-90af-9a6cbfb80040", "from":"2014-12-30T07:23:42.000Z", "to":"2015-01-14T05:11:51.000Z", "entryCount":801, "size":821472, "deprecated":false }, "status":[{ "node_id":"de713614-be3d-4c39-a3f8-1154957e46a6", "status":"PUBLISHED" }] } and I have a little code to transform that back into go structs type Status struct { status string node_id string } type Meta struct { to...

Unmarshaling XML in Go with Conflicting Element Names

xml,encoding,go,marshalling,unmarshalling
I have the following XML, externally defined and outside of my organization's control: <foo> <bar> <zip>zip</zip> </bar> <bar> <zap>zap</zap> </bar> </foo> I am using these structs: type Foo struct { XMLName xml.Name `xml:"foo"` Bar1 Bar1 Bar2 Bar2 } type Bar1 struct { XMLName xml.Name `xml:"bar"` Zip string `xml:"zip"` } type...

reconstruct python method with kwargs with marshal and types?

python,serialization,deserialization,marshalling,unmarshalling
I am using the marshal module to serialize some Python methods, and reconstruct them using types module (Is there an easy way to pickle a python function (or otherwise serialize its code)?). I am having trouble getting it to work with optional kwargs. E.g. import marshal import types def test_func(x,...

Null Pointer Exception in JAXB RI ClassFactory

java,xml,nullpointerexception,jaxb,unmarshalling
Intro My friend and I are working on a JavaFX application that acts as a planner for our school. We have tasks (homework for classes), events, courses and student info. In an attempt to store data persistently on the user's hard drive we are using JAXB. We have annotated our...

Returning a Java Vector from Server to Client using RMI

java,exception,rmi,unmarshalling
I'm new to RMI and I was trying to return a vector of a user-defined class to the client. I am getting an unmarshal exception. Here is my code. The exception I'm getting is:- java.rmi.UnmarshalException: error unmarshalling return; nested exception is: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: Text at sun.rmi.server.UnicastRef.invoke(Unknown Source) at...

Decode arbitrary JSON in Golang

json,dictionary,interface,go,unmarshalling
I have a question about decoding arbitrary JSON objects/messages in Go.. Lets say for example you have three wildly different JSON objects (aka messages) that you can receive on an http connection, lets call them for sake of illustration: { home : { some unique set of arrays, objects, fields,...

Unmarshalling XML to an Iterable using JAXB

java,xml,jaxb,unmarshalling
I have some very simple XML that I wish to unmarshall. I'm only interested in the values for one of the elements which repeats. Here's some sample XML: <Document> <HeaderGuff>Whatever</HeaderGuff> <Foos> <FooId>1</FooId> <FooId>2</FooId> </Foos> </Document> I would like to use JAXB to allow me to iterate of the FooId's as...

xml.Unmarshal error: expected element type but have

xml,go,unmarshalling,cocos2d-js
I try to unmarshal a XML file using xml.Unmarshal of "encoding/xml" package. The XML file starts like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>frames</key> <dict> <key>0</key> <dict> <key>frame</key> <string>{{0, 0}, {81, 145}}</string> <key>offset</key> <string>{0, 0}</string>...

JAXB: Unmarshal heterogeneous array

java,json,jaxb,unmarshalling,moxy
I'm trying to unmarshal using MOXy a json with the following structure: [ { "page": 1, "pages": 1 }, [ { "indicator": { "id": "IC.BUS.EASE.XQ", "value": "Ease of doing business index" }, "country": { "id": "1A", "value": "Arab World" }, "value": "113.952380952381", "date": "2014" }, ... ] ] The first...

Unmarshalling SubElements from XML Response

java,jaxb,unmarshalling
I am trying to unmarshall a XML Response. It is in the following structure <employee> <name> David </name> <age> 33 </age> <dateofjoin> <year>2012</year> <month>10</month> <day>01</day> </dateofjoin> </employee> Following is my Employee Class public class Employee { private Dateofjoin dateofjoin; private String name; private String age; public Dateofjoin getDateofjoin () {...

Strange unmarshalling behavior with union in C#

c#,boolean,unmarshalling,unions
I want to export a C-like union into a byte array, like this : [StructLayout(LayoutKind.Explicit)] struct my_struct { [FieldOffset(0)] public UInt32 my_uint; [FieldOffset(0)] public bool other_field; } public static void Main() { var test = new my_struct { my_uint = 0xDEADBEEF }; byte[] data = new byte[Marshal.SizeOf(test)]; IntPtr buffer =...

How to map a XML ignoring namespace using JAXB?

java,xml,jaxb,xml-namespaces,unmarshalling
I'm receiving a XML from a web service with the following format: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <string xmlns="http://someurl.com">somethingheresomethinghere</string> And I'm trying to unmarshall this to a POJO that looks like this: @XmlRootElement(name="string") public class StringValue { @XmlValue private String value; public StringValue () { } } And my unmarshalling code...

Golang Xml Unmarshal, No value

xml,go,unmarshalling
type VastHtml struct { VAST struct { Version string `xml:"version,attr"` Ad struct { Id string `xml:"id,attr"` InLine struct { AdSystem string `xml:"AdSystem"` AdTitle string `xml:"AdTitle"` Description string `xml:"Description"` Error string `xml:"Error"` Impression []string `xml:"Impression"` Creatives struct { Creative []struct { Sequence string `xml:"sequence,attr"` Id string `xml:"id,attr"` Linear struct { Duration...

JAXB Unmarshalling with outer and inner tags having same name and different attributes

java,xml,jaxb,unmarshalling
<xyz> <a attributeA, AttributeB> <b> </b> <c> <a attribute1,attribute2,attribute3/> </c> </a> </xyz> can anyone suggest me how to deal with 'a' innertag. ...

Why are string and []bytes treated differently when unmarshaling JSON?

json,go,unmarshalling
My understanding from reading the documentation was that string is essentially an immutable []byte and that one can easily convert between the two. However when unmarshaling from JSON this doesn't seem to be true. Take the following example program: package main import ( "encoding/json" "fmt" ) type STHRaw struct {...

Convert a part of Json to HashMap using Jackson ObjectMapper

java,json,jackson,unmarshalling,object-object-mapping
I am trying to unmarshall a json file in a way such that few properties of Json are mapped into a HashMap that is present in my model class.Rest of the properties are mapped to the respective fields of the class.Please find the Json below: { "_id":2, "Name":"xyz", "Age":20, "MEMO_TEXT":"yyy",...