unmarshalling

Unmarshall nested JSON Arrays in Go / Golang

情到浓时终转凉″ 提交于 2019-12-12 03:48:21
问题 Hi I have problem with unmarshalling nested JSON arrays. What struct should I create? I want to avoid using interface{} as much as possible, but I really don't know if it is possible in this case. Json I want to unmarshall: "[[[{\"aaa\": \"aaa\"}]]]" and struct I want to use to unmarshall this: type SomeStructNestedNested struct { Aaa string `json:"aaa"` } type SomeStructNested struct { SomeStructNestedNested []SomeStructNestedNested } type SomeStruct struct { SomeStructNested [

org.xml.sax.SAXException: Illegal Text data found as child of

天涯浪子 提交于 2019-12-12 03:33:34
问题 I´m trying to convert a xml to an Object in Spring MVC 4.x but I´m getting this error (just a piece of it): Caused by: org.xml.sax.SAXException: Illegal Text data found as child of: comprobante value: "<?xml version="1.0" encoding="UTF-8"?> <comprobanteRetencion id="comprobante" version="1.0.0"> <infoTributaria> <ambiente>2</ambiente> <tipoEmision>1</tipoEmision> <razonSocial> ... (resto del XML) at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:874) at org.exolab

What is a good way to handle single or array struct in golang json.Unmarshal?

梦想与她 提交于 2019-12-12 02:46:47
问题 I am building a stock quote web app by using Go and Yahoo API. The question is how to switch between array and single struct without writing another struct. I am not sure how to explain it in words. Here is the example: Get one symbol quote from Yahoo API looks like this: {"query":{"count":1,"created":"2016-05-11T02:12:33Z","lang":"en-US","results":{"quote":{"Change":"+0.21","DaysLow":"9.32","DaysHigh":"9.68","Name":"Alcoa Inc. Common Stock","Open":"9.56","PreviousClose":"9.46","Symbol":"aa",

Unmarshalling json by reversing the affect of @XmlElement renaming?

情到浓时终转凉″ 提交于 2019-12-12 02:14:16
问题 I have a class defined as follows: public class Contact implements Serializable { private final static long serialVersionUID = 1L; @XmlElement(name = "last-name", required = true) protected String lastName; @XmlElement(name = "first-name", required = true) protected String firstName; @XmlElement(required = true) protected String id; @XmlElement(name = "primary-phone") protected String primaryPhone; @XmlElement(name = "cellular-phone") protected String cellularPhone; } This class is being used

Trouble unmarshalling nested json with unknown keys

社会主义新天地 提交于 2019-12-12 01:22:21
问题 I am having trouble unmarshalling a json data of the below format to a struct. The structure of the json looks a bit confusing to me, so apologies for all the dumb things I am doing to unmarshal it. { "message": { "Server1.example.com": [ { "application": "Apache", "host": { "name": "/^Server-[13456]/" }, "owner": "User1", "project": "Web", "subowner": "User2" } ], "Server2.example.com": [ { "application": "Mysql", "host": { "name": "/^Server[23456]/" }, "owner": "User2", "project": "DB",

Trying to retrieve data from parcel

岁酱吖の 提交于 2019-12-12 01:19:35
问题 I have an Order Object that contains an ArrayList of MenuItem Objects. Both classes implement the Parcelable interface. When I attempt to retrieve the object from the Intent in the new activity I get the following error: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.waitron5/com.example.waitron5.SectionsActivity}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.example.waitron5.MenuItem Here is the code where I send the Order

Nested struct unmarshalling

。_饼干妹妹 提交于 2019-12-11 20:21:23
问题 There are two unmanaged structs typedef struct multipolynomial { int N; int max_power; double* X; double** Y; } multipolynomial; typedef struct output { double d; multipolynomial mp; } output; and corresponding managed analogs [StructLayoutAttribute(LayoutKind.Sequential)] public unsafe class Multipolynomial { public int n; public int max_power; public double* X; public double** Y; } [StructLayoutAttribute(LayoutKind.Sequential)] public unsafe struct Output { public double d; public

Spring RestTemplate cannot unmarshal XML containing “<!DOCTYPE … dtd>”

廉价感情. 提交于 2019-12-11 17:30:04
问题 I call an old web service provided by a third party. I am using Spring RestTemplate : HttpEntity<MyRequest> requestHttpEntity = new HttpEntity<>(requestBody, headers); MyResponse response = restTemplate.postForEntity(url, requestHttpEntity, MyResponse.class); I receive an XML (which format I cannot influence, it's a third party service) as a response: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE MyResponse SYSTEM "http://example.com:8080/some/path/MyResponse.dtd"> <MyResponse> ... <

How to unmarshal <!DOCTYPE> section In JAXB?

ⅰ亾dé卋堺 提交于 2019-12-11 13:35:52
问题 I need to unmarshal !DOCTYPE section using JAXB so I can get the values of file1 and file2. The xml file looks like this : <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE doc [ <!ENTITY file1 SYSTEM "conf/files/file1.xml"> <!ENTITY file2 SYSTEM "conf/files/file2.xml"> ]> <appels> <appel> &file1; </appel> <appel> &file1; </appel> </appels> the java look like this : @XmlRootElement(name = "appels") public class Appels implements Serializable { private List<Appel> appel; } I need to get file1 =

Passing values to interface{}

廉价感情. 提交于 2019-12-11 11:37:59
问题 Short The following code does not exactly do what expected: https://play.golang.org/p/sO4w4I_Lle I assume that I mess up some pointer/reference stuff as usual, however I expect my... func unmarshalJSON(in []byte, s interface{}) error ... and encoding/json s... func Unmarshal(data []byte, v interface{}) error ...to behave the same way (eg. update the referenced passed as second argument). Long The example above is a minimal reproducer that does not make much sense. This is in order to make it