deserialization

Serialize/Deserialize different property names?

只愿长相守 提交于 2019-12-11 10:36:19
问题 I have an old system which in a request info call returns xml with names that look like: postalCodeField, firstNameField... That same system then has a modify call which takes xml that looks like: PostalCode, fistName, lastName.... Is there a way to build an object that would deserialize the request, yet serialize the xml output with different names? Specifically: public class RequestInfo { public string firstNameField{get;set;} public string lastNameField{get;set;} } public class ModifyInfo

Java GSON Custom Deserializer versioning support

和自甴很熟 提交于 2019-12-11 09:53:39
问题 I created a custom deserializer for my Person class. This is just for demonstration purpose. My actual class is more complicated. The json file contains the version of the format and after that an array of persons. On version 1.0 i have a name and age for every person. On version 2.0 i have a name , age and additionally the gender . My problem here is that i do not have access to the version in the custom deserializer, or at least didn't figure out how to get it yet. Is there any other way to

Deserializing JSON child object values into parent object using JsonConvert.DeserializeObject<T> using nested converters

眉间皱痕 提交于 2019-12-11 09:53:04
问题 I'm receiving some oddly formatted JSON that I want to store in a single object. It looks something like this: { "parentObject": { "id": 123456, "pointlessChildObject": { "stringThatCouldBeStoredInParent": "test", "epochTimeThatCouldBeStoredInParent": "1520452800" } } } At first, I thought this would be simple thanks to a solution by Brian Rogers that I found: Can I specify a path in an attribute to map a property in my class to a child property in my JSON? However, if you implement this

Json dictionary result deserialization with RestSharp/Newtonsoft.Json.

谁都会走 提交于 2019-12-11 09:52:58
问题 I am using restsharp and a newtonsoft.json in order to communicate with my Python API. Communications works fine. Basic queries, which return simple strings are processed, so that's not a problem. I have problem with deserialization of more complex results and i am doing this for the first time. So, from web service point of view i am returning following json structure: { "Employee": [ { "Department.DepartmentName": "IT", "Employee.EmployeeArchived": 0, "Employee.EmployeeDepartmentId": 13,

IllegalAccessException - Serialization of object that inherits from non-serializable

元气小坏坏 提交于 2019-12-11 09:19:37
问题 I getting android.widget.ImageView; IllegalAccessException when trying to deserialize my previously serialized object File presetFile = new File("pathToFile"); FileInputStream fis = new FileInputStream(presetFile); ObjectInputStream ois = new ObjectInputStream(fis); Preset preset = (Preset) ois.readObject(); I'm guessing that there is some restriction about ImageView, explanation below: public class Preset implements Serializable { private Date dateOfCreation; private int bpm; private

ModelBinding not deserializing json

梦想与她 提交于 2019-12-11 09:15:10
问题 I'm using MVC 5, Web API 2 with Entity Framework 6 in vs 2012. I'm able to successfully call the right action in my web api controller but the incoming json is never deserialized, or at least not properly. The modelBinding recognizes that the json in the request matches the argument Type for the Post action but every property is null or default value. Why is the json not being deserialized? I can't see any issues here. This not an active url, just something setup on my local POST http://www

What is the fastest and easiest way to communicate between 2 processes in C#?

牧云@^-^@ 提交于 2019-12-11 09:00:49
问题 From my main c# app, I start many slave process with Process.Start method. (on the same PC) Just before starting those slave process, I serialize some data (I have serialized class) in XML files which are passed in the arguments of Process class. In each slave process, those data are deserialized and a computation is done. A new serialization is done to XML in order to send result to the main process. My apps works but the performance are very bad. The time of serialization/deserialization

PHP: Custom Session Handler Unserialize Not Working on Windows

人走茶凉 提交于 2019-12-11 08:55:27
问题 The development environment of my application is Zend Framework 1.11, MSSQL Server 2012, SQLSRV Extension for Database connectivity with PDO, Windows 7, IIS 7. Session is being stored in database by using custom session handler class. The issue is that when i print $_SESSION after session_start() which is written in Bootstrap.php file, it does not show complete unserialized array of session data. It seems that session data which is being returned by "read" method of session class handler, not

Custom Model Binding MVC

此生再无相见时 提交于 2019-12-11 08:39:42
问题 I'm trying to pass a list of JSON objects to a controller method, and automatically have the correct types defined and populated in the controller. JSON Posted to controller: { Type : 'Image', ImageName : 'blah.jpg' }, { Type : 'Text', Text: 'Hello', Font: 'Some Font' }.. The Controller: public ActionResult SaveCOntent(IList<Item> content) So the impression i've got is that I need to use ModelBinding to convert the elements into the correct type. I've tried following another suggested post

Deserialize Json using dynamic object or model

本秂侑毒 提交于 2019-12-11 08:25:47
问题 I have been trying to convert the below json into a C# model: { "Meta Data": { "1. Information": "Intraday (1min) prices and volumes", "2. Symbol": "MSFT", "3. Last Refreshed": "2017-07-25 16:00:00", "4. Interval": "1min", "5. Output Size": "Compact", "6. Time Zone": "US/Eastern" }, "Time Series (1min)": { "2017-07-25 16:00:00": { "1. open": "74.2500", "2. high": "74.2800", "3. low": "74.1900", "4. close": "74.1900", "5. volume": "2698886" }, "2017-07-25 15:59:00": { "1. open": "74.1400", "2.