Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js object to c# object

// Construct a object in JS

var obj = {
  id: 0 ,
  userName: 'Bill'
};

// C# class:

public class myClass
{
  public int id;
  public string userName;
}

// Then for example using AJAX send your data to C#,
// and deserialize, when you need work with object

$.ajax({
	type: "POST",
  	// Note that you need to pass the method as url
	url: '<your server url>' + 'DeserializeObject',
  	// your data is the object you want to send
	data: obj,
	contentType: "application/text; charset=utf-8",
	dataType: "text"
})

[HttpPost]
public void DeserializeObject(string objJson)
{
var obj = (new JavascriptSerializer()).Deserialize<myClass>(objJson);
}
Comment

c# to javascript object

// 1st c# code to json
https://csharp2json.io/

// then convert json to object 
https://www.convertsimple.com/convert-json-to-javascript/
Comment

PREVIOUS NEXT
Code Example
Javascript :: java scrypt 
Javascript :: add seconds to date 
Javascript :: event 
Javascript :: convert c# code to javascript 
Javascript :: empty an array in javascript 
Javascript :: password generator and password strength using javascript 
Javascript :: ng-options angularjs 
Javascript :: promise object 
Javascript :: use of prototype in javascript 
Javascript :: for loop javascript array of objects 
Javascript :: window location href 
Javascript :: switch 
Javascript :: jwt_access_secret generator 
Javascript :: regex javscript 
Javascript :: hello world in react 
Javascript :: chatbot js 
Javascript :: client position js 
Javascript :: heroku 
Javascript :: js spin wheel color 
Javascript :: JavaScript Changing Prototype 
Javascript :: javascript Access Set Elements 
Javascript :: javascript Regular Expression Modifier 
Javascript :: ejs split string 
Javascript :: Multiply string using a for loop 
Javascript :: stack array in localStorage 
Javascript :: phaser place items on circle 
Javascript :: phaser animation random delay 
Javascript :: remove text in div JQuery zqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq 
Javascript :: nodejs mongodb native reuse single connection 
Javascript :: mogoose schema to add json as a property 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =