要匹配Json字符串的类 [英] Class to Match Json string
问题描述
我在设置课程时遇到问题,并且与我建立的Json课程相匹配。
工作Json字符串:
" {\\\\\\ quot; userName \":\" testuser99@aha.org\" ;, \\\\ n \" mail \":\" testuser99@aha.org\" ;, \\\\ n \" givenName \":\" Test \",\\\\ n
\" sn \":\" User3 \",\\\\ n \" accountStatus \":\" Active \","\\ \\ a \ \\ n \" avectraId \":\" 9999999678 \",\\\\ n \ \\"AHApw \":\\\\ ; / Z5 / 5OXUBquzAtXesIjN0WjxFp1z05jMXKoynFyVKwa1 + RdaUxmrFU6 / nCOLedqh \",\\\\ n
\" password \" :\" Password1 \",\\\\ n \" ahaBirthYear \" :\" 1980 \",\\ n \" city \" :\" Chicago \",\\\\ n \" ahaGender \" :\" Female \",\\\\ n \" ahaJobTitle \" :\" CNO \",\ r \ n
\" ahaLeadScore \" :\" 101 \",\\\\ n \" stateProvince \" :\" IL \",\\ n \"orgId \" :\" 0006430024 \",\\\\ n \" ahaMemberGroup \" :[\\\\ n \" AHA \",\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ; ahaMemberType\"
:[\\\\ n \"I-B \",\\\\ n \" FULL \"\\\\ n \\ n",\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\ r \ n"
这是我的班级,但是当我转换为Json时,它不匹配。
public class IdentityDetails
{
// public const string type =" user" ;;
// public const string realm =" dc = aha,dc = org" ;;
公共字符串用户名{get;组; }
public string mail {get;组; }
public string givenName {get;组; }
public string sn {get;组; }
public string accountStatus {get;组; }
public string avectraId {get;组; }
public string AHApw {get;组; }
公共字符串密码{get;组; }
public string ahaBirthYear {get;组; }
public string city {get;组; }
public string ahaGender {get;组; }
public string ahaJobTitle {get;组; }
public string ahaLeadScore {get;组; }
公共字符串stateProvince {get;组; }
public string orgId {get;组; }
public string [] ahaMemberGroup {get;组; }
public string [] ahaMemberType {get;组; }
public string regMethod {get;组; }
// public string [] ahaDrupalPermission {get;组; }
}
转换输出:
代码:
var json = JsonConvert.SerializeObject(obj);
试试这个发电机
I'm having issues getting my class setup to match this Json class I built.
Working Json string:
"{\r\n \"userName\": \"testuser99@aha.org\",\r\n \"mail\": \"testuser99@aha.org\",\r\n \"givenName\": \"Test\",\r\n \"sn\": \"User3\",\r\n \"accountStatus\": \"Active\",\r\n \"avectraId\": \"9999999678\",\r\n \"AHApw\":\r\n\"/Z5/5OXUBquzAtXesIjN0WjxFp1z05jMXKoynFyVKwa1+RdaUxmrFU6/nCOLedqh\",\r\n \"password\" : \"Password1\",\r\n \"ahaBirthYear\" : \"1980\",\r\n \"city\" : \"Chicago\",\r\n \"ahaGender\" : \"Female\",\r\n \"ahaJobTitle\" : \"CNO\",\r\n \"ahaLeadScore\" : \"101\",\r\n \"stateProvince\" : \"IL\",\r\n \"orgId\" : \"0006430024\",\r\n \"ahaMemberGroup\" : [\r\n \"AHA\",\r\n \"AONE\"\r\n ],\r\n \"ahaMemberType\" : [\r\n \"I-B\",\r\n \"FULL\"\r\n ],\r\n \"regMethod\": \"AMS\"\r\n}\r\n"
Here is my class, but when I convert to Json it does not match.
public class IdentityDetails { //public const string type = "user"; //public const string realm = "dc=aha,dc=org"; public string username { get; set; } public string mail { get; set; } public string givenName { get; set; } public string sn { get; set; } public string accountStatus { get; set; } public string avectraId { get; set; } public string AHApw { get; set; } public string password { get; set; } public string ahaBirthYear { get; set; } public string city { get; set; } public string ahaGender { get; set; } public string ahaJobTitle { get; set; } public string ahaLeadScore { get; set; } public string stateProvince { get; set; } public string orgId { get; set; } public string[] ahaMemberGroup { get; set; } public string[] ahaMemberType { get; set; } public string regMethod { get; set; } //public string[] ahaDrupalPermission { get; set; } }
Conversion Output:
Code:
var json = JsonConvert.SerializeObject(obj);
Try this generator
这篇关于要匹配Json字符串的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!