serialization

Can Json.NET deserialize a flattened JSON string with dot notation?

你离开我真会死。 提交于 2020-07-18 04:13:31
问题 I have a flattened JSON: { "CaseName" : "John Doe v. State", "CaseDate" : "<some date>", "Client.FirstName" : "John", "Client.LastName" : "Doe", "Client.Email" : "johndoe@gmail.com" etc... } I want to deserialize it back to this entity: public class Case() { public string CaseName { get; set; } public string CaseDate { get; set; } public Client Client { get; set; } } where Client.FirstName , Client.LastName , and Client.Email are properties in the Client object. Using Json.NET, is there any

Can Json.NET deserialize a flattened JSON string with dot notation?

你。 提交于 2020-07-18 04:13:05
问题 I have a flattened JSON: { "CaseName" : "John Doe v. State", "CaseDate" : "<some date>", "Client.FirstName" : "John", "Client.LastName" : "Doe", "Client.Email" : "johndoe@gmail.com" etc... } I want to deserialize it back to this entity: public class Case() { public string CaseName { get; set; } public string CaseDate { get; set; } public Client Client { get; set; } } where Client.FirstName , Client.LastName , and Client.Email are properties in the Client object. Using Json.NET, is there any

Replace sensitive data value on JSON serialization

旧时模样 提交于 2020-07-17 10:35:23
问题 I have some objects that I want to serialize as JSON. However, some of the objects have properties which are deemed 'SensitiveData' via attributes. [SensitiveDataAttribute] public string SomeSensitiveProperty {get; set;} At the moment, I am overriding the 'CreateProperty' method on the serializer so that I can alter whether or not a property should be serialized dependent upon whether it has this 'SensitiveData' attribute: public class SensitiveDataResolver : DefaultContractResolver {

Python marshmallow tree structure with polymorphism

寵の児 提交于 2020-07-16 06:52:33
问题 I have the following code for a tree structure: class Node: def __init__(self, node_id: str): self.node_id = node_id self.children = [] def add_child(self, node: 'Node'): if isinstance(node, Node): self.children.append(node) class ValueNode(Node): def __init__(self, value: bool, **kwargs): Node.__init__(self, **kwargs) self.value = value class LogicNode(Node): def __init__(self, logic_operator: str, **kwargs): Node.__init__(self, **kwargs) self.logic_operator = logic_operator a = Node("a") b

Deserialize json object xamarin android c#

烂漫一生 提交于 2020-07-14 07:04:10
问题 I have little issue with deserialize json object. My json from http url: Screen of my downloaded JSON I don't know how to deserialize to make dynamically creating buttons. I figure out how to create buttons with text, but I don't know how to make them with options that they have. I try to get these options in Windows Form app for test, but app will crash. Thank you for help. 回答1: Your classes should be something like: public class Type { public int id { get; set; } public string name { get;

How do I pass ArrayList<Object> from one Activity to another Activity

我与影子孤独终老i 提交于 2020-07-10 10:27:28
问题 I want to pass ArrayList of an Object from one Activity to Activity. Here is the sample Code: { ArrayList<object> list=new ArrayList<>(); Object value[]=new Object[m.size()]; int n=0; value[]=new Object[n]; value[n]=data.getName("name"); value[n]=data.getLocation("location"); list.add(value[n]); n++; //Since there are "n" number of object } //here the value a which is ArrayList Object // which I want to pass it from here to another activity. So now how will I pass the object from here to

Setting a value in a Nullable<T> record with RTTI

旧时模样 提交于 2020-07-09 17:13:24
问题 I'm working with Serialization/Deserialization using NEON library from Paolo Rossi. i'm trying to populate this class using RTTI, with data that i get from a database. The properties on the class have the same name of the fields in the database. In the library, i have this Nullable Record : unit Neon.Core.Nullables; interface uses System.SysUtils, System.Variants, System.Classes, System.Generics.Defaults, System.Rtti, System.TypInfo, System.JSON; type ENullableException = class(Exception); {

How to serialize fields with custom names using snake yaml in Java

限于喜欢 提交于 2020-07-09 13:52:07
问题 I'm trying to serialize a Java instance having fields like follows. public class Person{ private String firstName; private String lastName; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } } How do I serialize them in different names than the actual field names? In Gson this is possible by using

How to fix Error Type 'System.Web.Script.Serialization.JavaScriptSerializer' is not defined

佐手、 提交于 2020-07-08 06:12:27
问题 The super obvious way is to add reference to System.web I did that. It doesn't work. 回答1: Add a reference to System.Web.Extensions http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx Namespace: System.Web.Script.Serialization Assembly: System.Web.Extensions (in System.Web.Extensions.dll) 回答2: How to add System.Web.Extensions in Visual Studio 2012: Right-click your project. Click "Properties" Click the "References" tab on the left. Click the "Add"

How to fix Error Type 'System.Web.Script.Serialization.JavaScriptSerializer' is not defined

蹲街弑〆低调 提交于 2020-07-08 06:12:06
问题 The super obvious way is to add reference to System.web I did that. It doesn't work. 回答1: Add a reference to System.Web.Extensions http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx Namespace: System.Web.Script.Serialization Assembly: System.Web.Extensions (in System.Web.Extensions.dll) 回答2: How to add System.Web.Extensions in Visual Studio 2012: Right-click your project. Click "Properties" Click the "References" tab on the left. Click the "Add"