Hi, am new to Json so a little green.
I have a Rest Based Service that returns a json string;
{"treeNode":[{"id":"U-2905","pid":"R","userId":"2905"},
{"id":"U-2905","pid":"R","userId":"2905"}]}
I have been playing with the Json.net and trying to Deserialize the string into Objects etc.
I wrote an extention method to help.
public sta...
I want to use Goolge AJAX Feed API in my C# console application to save return feeds as C# collection so i can use this .net collcetion in my .net application.
I noticed google give a Java Access Code Snippets but I have no idea how to coding it in C#.
I know there is a very good .net opensource library Json.NET we can use to read and ...
I have a class looking like this:
class MyClass {
public int Id;
public Dictionary<int, MyClass[]> ChildValues;
}
when I try to deserialize this class using Json.NET:
MyClass x = return JsonConvert.DeserializeObject<MyClass>(s);
I receive the error Expected a JsonObjectContract or JsonDictionaryContract for type 'System.Co...
I am attempting to parse some JSON content in to C#. For the simpler cases I am having great success with JSON.NET and really appreciate the clean approach offered by the LINQ provider. Here's an example where I'm downloading information about a layer in a map and filling in some properties on a class called (suprisingly!) Layer:
...
I looked at this http://stackoverflow.com/questions/401756/parsing-json-using-json-net question and answer and it's close to what I need. The critical difference Is that I need to parse an array of x,y pairs that form one or more lines per record. Here's an example of my input
{
"displayFieldName" : "FACILITYID",
"fieldAliases" : {
"FA...
Hi everyone! I'm very new to JSON, and I need to parse some that an API is providing. A quick google search turned up JSON.NET, so I'm trying to use it now to parse this JSON into a list object. First of all, is JSON.NET the best library to use for this?
This is what I'm trying to do: I have a class called Item, for example. The json ha...
Hi
I have the following code and json:
public class Labels
{
public Labels()
{}
public Label[] Label {get;set;}
}
public class Label
{
public Label()
{ }
public string Name { get; set; }
public int TorrentsInLabel { get; set; }
}
//...
Labels o = JsonConvert.DeserializeObject<Labels>(json);
//...
{"labe...
By default WCF service wrap JSON response in "d" wrapper and there I found a problem with parsing it.
If I parse with JsonConvert.DeserializeObject(response) where response is
"{\"d\":\"{\"a0b70d2f-7fe4-4aa2-b600-066201eab82d\":\"Thelma\",\"d56d4d4f-6029-40df-a23b-de27617a1e43\":\"Louise\"}\"}"
I gor an Error:
After parsing a value ...
I need to scan inbound string properties sent to a C# coded web server. The scan should strip out any JavaScript injection threat before my web server stores client supplied data in a database server-side.
All of these inbound strings will be properties within json data structs.
It occurs to me that the ideal and most reliable place to...
At present the structure of my code uses XmlDocument to load Xml and then SelectNodes to iterate through a list of repeating items. For each elements Im using XmlNode.SelectSingleNode to pick out field elements.
I now want to use JSON.NET to achieve the same results with documents delivered to me as Json. The answer can be something oth...
Hi there,
I've just found out little oddity in behaviour of James Newton-King's library JSON.NET. I'm using it for deserialization of client side JSON custom "features", and everything works - even validity test. Until client sends another type of "feature":
CustomJSONConverter converter=new CustomJSONConverter();
MyJSONFeature jsonFea...
Which .NET JSON serializers can deal with NHibernate proxy objects? I tried using JSON.NET but it craps out when it hits a proxied object.
...
Hi,
I'm trying to deseralize some json into a collection (list), but I'm not sure which method will return a list of objects, or do I have to loop through something and copy it to my own list?
Can anyone tell me the syntax or method I should use for this.
I've created my object with some properties, so it's ready to be used to hold th...
I'd like to serialization a class inherited from Collection and save both the items and the ActivePageIndex,
if I use JsonArrayAttribute, I only got the items saved,
if I use JsonObjectAttribute, I only got string "(Collection)".
Is there anyway to do it?
[JsonObject(MemberSerialization.OptIn)]
public class Pages : ObservableCollectio...
I am trying to use asp.net MVC controllers JsonResult to CRUD db records.
e.g.
GET /Config/Folder/1 - will return a json serialized LinqToSql entity
POST /Config/Folder - will send form data back to the server to be deserialized and persisted back to the database.
I am using james newton-kings JSON.net to serialize the entity, althou...
Question: The JavaScript code below:
records is JSON serialized data.
I can access it right away from JavaScript by using for example
alert(records.data[0].Phone);
The problem now is that some bright spark used a whitespace in FirstName and LastName, which means I would have to access it like
alert(records.data[0].Last Name); Which...
I have a class:
[Serializable]
public class KVPair<TKey, TValue>
{
public TKey Key { get; set; }
public TValue Value { get; set; }
public KVPair(TKey k, TValue v)
{
Key = k;
Value = v;
}
}
that I create:
List<KVPair<string,string>> kvPairs;
Using the J...
I want to expose a service on my site that any users can call and get a JSON response. In the end, I want the users to be using this service as much as possible.
My site is created using the asp.net MVC framework and i was wondering whats the best way to do this...
I think most would say it's obvious to use a web service (*.asmx) that ...
I'm using JSON.NET to serialize and deserialize object for different purposes. I'm a big fan of DI but the code below gives me the chills. Is smells like bad code:
public class Foo : Baz
{
private readonly IBar bar;
public Foo()
: this(ObjectFactory.GetInstance<IBar>())
{ }
public Foo(IBar bar)
{
if ...
I'm trying to convert JSON to C# object using Json.NET. The object looks like this in C#:
public class MyObject
{
public int? integerValue {get;set;}
public DateTime? dateTimeValue {get;set;}
}
But when I run JsonConvert.DeserializeObject() on the incoming JSON, I get the following Exception:
Unable to find a constructor t...