Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

ExpandoObject Convert to Json or Json to ExpandoObject

//  if you add the NewtonSoft.Json NuGet package to your project,
// you can convert your object to a string with this single line of code:
string strCust = JsonConvert.SerializeObject(cust, new ExpandoObjectConverter());

// To convert that string back to your original ExpandoObject, you'll use code like this:
cust = JsonConvert.DeserializeObject<ExpandoObject>(res, new ExpandoObjectConverter());

// This will do a great job of serializing your properties and will normally ignore any methods you added (probably what you want). 
// The one exception is if you have a method that refers to itself (as the example in my previous column did). 
// In that scenario the serialization code will blow up.
Comment

PREVIOUS NEXT
Code Example
Csharp :: switch rows and columns in a datagridview 
Csharp :: How to set a Printer Port in C# on a specified Printer 
Csharp :: SerializedObjectNotCreatableException: Object at index 0 is null 
Csharp :: c# regex double of some letters only 
Csharp :: c# task call more web api in parallel 
Csharp :: inline c# custom operator implicit 
Csharp :: Display all members of class using a for loop vb.net 
Csharp :: how to find any component of gameobject itself in untiy 
Csharp :: unrecognized escape sequence c# connection string 
Csharp :: material Array setter 
Csharp :: c# variable 
Csharp :: c# single comment 
Csharp :: return a list of list from yaml via C# 
Csharp :: unity check if object is being rendered 
Csharp :: C# signup code 
Csharp :: jtoken value is not exact 
Csharp :: invalid length for a base-64 char array or string. frombase64string c#Add Answer 
Csharp :: convert physical path to virtual path in c# 
Csharp :: how to extract unique years from a list of different years in c# 
Csharp :: .net core executenonqueryasync transaction 
Csharp :: C# if with obj params 
Csharp :: telerik mvc grid unbound column 
Csharp :: c# .net set exception data 
Csharp :: initialize c# array property of class object site:stackoverflow.com 
Csharp :: kentico 13 api save attachment 
Csharp :: c# Detect Cycle in a Directed Graph 
Csharp :: difference between all logging framework .NET Core? 
Csharp :: mouse position to canvas transform 
Csharp :: c# instantiation 
Csharp :: character stay in ground unity 3d 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =