unmarshalling

How do I call this c function in c# (unmarshalling return struct)?

人走茶凉 提交于 2019-12-05 02:59:32
I want to use c# interop to call a function from a dll written in c. I have the header files. Take a look at this: enum CTMBeginTransactionError { CTM_BEGIN_TRX_SUCCESS = 0, CTM_BEGIN_TRX_ERROR_ALREADY_IN_PROGRESS, CTM_BEGIN_TRX_ERROR_NOT_CONNECTED }; #pragma pack(push) #pragma pack(1) struct CTMBeginTransactionResult { char * szTransactionID; enum CTMBeginTransactionError error; }; struct CTMBeginTransactionResult ctm_begin_customer_transaction(const char * szTransactionID); How do I call ctm_begin_customer_transaction from c#. The const char * mapps well to string, but despite various

Invalid XML Character During Unmarshall

拜拜、爱过 提交于 2019-12-05 02:35:45
I am marshalling objects to XML file using encoding "UTF-8". It generates file successfully. But when I try to unmarshal it back, there is an error: An invalid XML character (Unicode: 0x{2}) was found in the value of attribute "{1}" and element is "0" The character is 0x1A or \u001a, which is valid in UTF-8 but illegal in XML. Marshaller in JAXB allows writing this character into XML file, but Unmarshaller cannot parse it back. I tried to use another encoding (UTF-16, ASCII, etc) but still error. The common solution is to remove/replace this invalid character before XML parsing. But if we need

Golang json Unmarshal “unexpected end of JSON input”

主宰稳场 提交于 2019-12-05 00:55:24
I am working on some code to parse the JSON data from an HTTP response. The code I have looks something like this: type ResultStruct struct { result []map[string]string } var jsonData ResultStruct err = json.Unmarshal(respBytes, &jsonData) The json in the respBytes variable looks like this: { "result": [ { "id": "ID 1" }, { "id": "ID 2" } ] } However, err is not nil. When I print it out it says unexpected end of JSON input . What is causing this? The JSON seems to valid. Does this error have something to do with my custom struct? Thanks in advance! Cerise Limón The unexpected end of JSON input

JAXB (un)marshalling of xsd types: xsd:base64Binary and xsd:hexBinary

不羁的心 提交于 2019-12-05 00:37:09
问题 JAXB maps both xsd:base64Binary and xsd:hexBinary types to byte[] . Given that I have a schema/a DOM Element representing each of these types such as: <foo>ABCD</foo> for xsd:hexBinary and <foo>YTM0NZomIzI2OTsmIzM0NTueYQ==</foo> for xsd:base64Binary , it's not clear how JAXB 2.1 handles it. JAXB.unmarshal(new DOMSource(node), byte[].class) does not like the payload. Neither does the following: JAXBContext ctx = JAXBContext.newInstance(byte[].class); ctx.createUnmarshaller().unmarshal(node);

Unmarshal CSV record into struct in Go

只谈情不闲聊 提交于 2019-12-04 19:00:27
问题 The problem how to automatically deserialize/unmarshal record from CSV file into Go struct. For example, I have type Test struct { Name string Surname string Age int } And CSV file contains records John;Smith;42 Piter;Abel;50 Is there an easy way to unmarshal those records into struct except by using "encoding/csv" package for reading record and then doing something like record, _ := reader.Read() test := Test{record[0],record[1],atoi(record[2])} 回答1: Seems I've done with automatic marshaling

Unmarshal error in JAXB

心已入冬 提交于 2019-12-04 17:37:36
This is the generated code for "PersonType" class. package demo; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "PersonType", propOrder = { "name", "address" }) public class PersonType { @XmlElement(name = "Name", required = true) protected String name; @XmlElement(name = "Address", required = true) protected List<AddressType> address; public String

XML unmarshalling using JAXB

半世苍凉 提交于 2019-12-04 17:21:26
I have an XML file that I'm trying to unmarshal, but I cant figure out how to do it. XML looks like <config> <params> <param> <a>draft</a> <b>Serial</b> </param> <param> <a>amt</a> <b>Amount</b> </param> </params> <server> <scheme>http</scheme> <host>somehost.com/asdf</host> </server> </config> I could previously unmarshall when I had params as the root element and didnt have the server elements or config as root element. I added a config class to try to unmarshall this, but I dont know where I'm going wrong. My classes look like @XmlRootElement public class Config { private Params params =

Unmarshal Inconsistent JSON in Go

五迷三道 提交于 2019-12-04 15:32:30
I'm working with JSON that returns three different object types 'items','categories' and 'modifiers'. An example of the JSON can be viewed here. I created models for the three types of objects. But when I unmarshal I have selected one of the types to unmarshal the entire JSON to.(I know this cant be the correct way...) I then try to parse out the different items depending on what their type is identified as in the json field 'Type' and then append that object to a slice of the proper type. I am having errors because I don't know how to unmarshal JSON that has different types in it that have

Is using Parcelable the right way to send data between applications?

☆樱花仙子☆ 提交于 2019-12-04 12:15:34
问题 I am trying to understand how to communicate between applications in Android - not just between Activity instances. I set up a 'client' that sends a Messenger obj to a Service (in the Intent sent to the service); the service creates a Message obj and sends it back to the 'client' using messenger.send(message) . This works fine until I try to use the Message.obj to hold an object. I created my own Parcelable class MyParcelable in the service and put it into the message. All works until the

Parse MathType MTEF data from OLE binary string

こ雲淡風輕ζ 提交于 2019-12-04 10:19:42
There is a need to convert the MathType equations in the MS-WORD 2003 or below to MathML in order to render nicely on the the web. The MathType's built in function "Publish to MathPage" can do the job very nicely, but I want to integrate the equation conversion process in my C# application. Because I couldn't find any API references that the MathPage export interface is provided by the MathType SDK, I need to figure out a way to do the individual equation conversion by myself. The current procedure is to convert the MS-WORD 2003 or below documents into the Open XML format(docx). After the docx