Reference Object Property with JSON.Net when property has special characters



I am using JSON.Net to update an object within an XML File. This works great! However, I need to update a property that has some special charecters in it and I can't find any information out there on how to do this with JSON.Net.


XML



<ProfileSettings>{
"Name": "Default",
"Status": "New",
"DeploymentVariants": {
"SPSite": {
"Signature": "SPSite",
"Type": "SPSite",
"Label": "SharePoint Site",
"Source": "Solution",
"DefaultValue": "http://google.com",
"Value": "http://google.com"
},
"Process/Participant[@Name=\"Manager\"]&gt;User": {
"Signature": "Process/Participant[@Name=\"Manager\"]&gt;User",
"Type": "SPUser",
"Label": "User for swim lane Manager",
"Source": "Swimlane",
"DefaultValue": "John Smith",
"Value": "John Smith"
}
},
"DeploymentScripts": {},
"SPList": "mySPList"
}</DeploymentProfile>


In order to update the DefaultValue in the SPSite Object, I can use JSON.Net like so:



dynamic fromSolution = JsonConvert.DeserializeObject(profileObject);
fromSolution.DeploymentVariants.SPSite.DefaultValue = txtSPSite.Text;


However, this won't be true if I'm trying to access the Process/Participant[@Name=\"Manager\"]>User object. How can I access a property when it's got special characters like this one?


fromSolution.DeploymentVariants.Process.DefaultValue did not work and obviously including special charecters within that will just result in runtime errors.


No comments:

Post a Comment