serialization

WCF doesn't serialize all properties

余生颓废 提交于 2019-12-21 01:59:23
问题 I'm consuming a SOAP service that has been imported as a Service Reference in VS2010. I call one of the services with a request object that is provided by the service. The problem I'm having is that not all properties of the object are serialized, or rather not sent over the wire. The request object looks like this: var serviceRequest = new UpdateRequest{ StoreId = request.StoreId, Id = request.Id, Status = (Status)Enum.Parse(typeof(Status), request.myStatus.ToString()), parameters = request

DataContractSerializer, KnownType and inheritance

一世执手 提交于 2019-12-21 01:57:10
问题 I've read many articles about known types and i belive my example should work. But it doesn't. I'm getting the following exception on deserialization and don't understand why: Error in line 1 position 2. Expecting element 'A' from namespace 'http://schemas.datacontract.org/2004/07/ConsoleApplication2'.. Encountered 'Element' with name 'C', namespace 'http://schemas.datacontract.org/2004/07/ConsoleApplication2'. using System; using System.Runtime.Serialization; using System.Xml; using System

DataContract Serialize abstract class

孤者浪人 提交于 2019-12-21 01:20:16
问题 I have an interface IServiceInfo and an abstract class ServiceInfo. There are several classes inherited from ServiceInfo, like CoreServiceInfo, ModuleServiceInfo etc. There is a service contract named RootService which returns IServiceInfo. public IServiceInfo GetServiceInfo() { return (IServiceInfo)new CoreServiceInfo(); } I am having problem serializing. I can use ServiceKnownType to identify base class, and KnownType to identify child class. Problem is I do not know all the ServiceInfo

How to serialize hierarchical relationship in Django REST

大憨熊 提交于 2019-12-21 00:00:12
问题 I have a Django model that is hierarchical using django-mptt, which looks like: class UOMCategory(MPTTModel, BaseModel): """ This represents categories of different unit of measurements. """ name = models.CharField(max_length=50, unique=True) description = models.CharField(max_length=50, unique=True) parent = TreeForeignKey('self', null=True, blank=True, related_name='%(app_label)s_%(class)s_sub_uom_categories') The problem now is I created a REST API using Django REST Framework; how do I

Recommendations for persisting data on Android?

狂风中的少年 提交于 2019-12-20 21:30:29
问题 There is a web service that provides some data that my app makes use of. This data is fairly large and only changes VERY infrequently so I thought it would be nice if the app could cache it on the SD Card and only update it as needed. Currently I'm grabbing the data (an XML file) and parsing it into an object tree using SAX. This process takes (at most) 2-3 seconds over my WIFI. However, serializing the resulting objects to the SDCard takes significantly longer (a minute or more) and

XML Serialization in C#

大兔子大兔子 提交于 2019-12-20 20:31:15
问题 Where Can I find good tutorial about XMl serialization to the object? Thanks. 回答1: There's a basic tutorial on Microsoft's support pages and their code example is only a few lines long: using System; public class clsPerson { public string FirstName; public string MI; public string LastName; } class class1 { static void Main(string[] args) { clsPerson p=new clsPerson(); p.FirstName = "Jeff"; p.MI = "A"; p.LastName = "Price"; System.Xml.Serialization.XmlSerializer x = new System.Xml

How to serialize an array and deserialize back

纵饮孤独 提交于 2019-12-20 19:56:12
问题 How do I serialize an array and deserialize it back from a string? I tried the following code, but it doesn't really return the original array of integers but does for the array of strings. x = [1,2,3].join(',') # maybe this is not the correct way to serialize to string? => '1,2,3' x = x.split(',') => [ '1', '2', '3' ] Is there a way to get it back to integers without having the .collect{ |x| x.to_i } ? 回答1: The standard way is with Marshal : x = Marshal.dump([1, 2, 3]) #=> "\x04\b[\bi\x06i

Serializing the errors hash in ActiveModel::Serializer

独自空忆成欢 提交于 2019-12-20 19:46:23
问题 I'm using ActiveModel::Serializer to customize the JSON responses for my API. This works fine in most cases, except when it fails to save a model successfully. For example, def create def create book = Book.new(book_params) book.save respond_with book, location: nil end end As I understand it, the respond_with action will basically execute code that looks something like this (in order to generate the response). if resource.errors.any? render json: {:status => 'failed', :errors => resource

serialize from a table element and not the whole form

匆匆过客 提交于 2019-12-20 19:43:46
问题 Trying to serialize just the elements from a specific table but it only returns a result if i do the whole Form in the below code, i want to ajax just the elements in tbl2 <form> <input type="text" id="tb1" name="tbl1"/> <table name="tbl1"> <tr><td><input type="text" name="tb2"/></td></tr> </table> <table name="tbl2"> <tr><td><input type="text" name="tb3"/></td></tr> <tr><td><input type="text" name="tb4"/></td></tr> </table> </form> the code var params = $("#tbl2").serialize(); var resp = $

How to serialize to JSON in Qt

江枫思渺然 提交于 2019-12-20 19:43:13
问题 How can I JSON serialize a QVariant (or other type of data) in Qt. I don't want to use an external third party library like QJson 回答1: Just to mention, as of Qt5, JSON is officially supported: JSON Support in Qt QVariant id(1), name("John Doe"); QJsonObject json; json["Name"] = name.toString(); json.insert("id", id.toInt()); 回答2: Parsing JSON with QT using standard QT library. BTW: why don't you want to use QJson? It nicely encapsulates all the QScriptValueIterator stuff, making your code