json.net

Deserialize json array stream one item at a time

谁说胖子不能爱 提交于 2020-01-08 12:27:53
问题 I serialize an array of large objects to a json http response stream. Now I want to deserialize these objects from the stream one at a time. Are there any c# libraries that will let me do this? I've looked at json.net but it seems I'd have to deserialize the complete array of objects at once. [{large json object},{large json object}.....] Clarification: I want to read one json object from the stream at a time and deserialize it. 回答1: In order to read the JSON incrementally, you'll need to use

Making a property deserialize but not serialize with json.net

自闭症网瘾萝莉.ら 提交于 2020-01-08 11:34:46
问题 We have some configuration files which were generated by serializing C# objects with Json.net. We'd like to migrate one property of the serialised class away from being a simple enum property into a class property. One easy way to do this, would be to leave the old enum property on the class, and arrange for Json.net to read this property when we load the config, but not to save it again when we next serialize the object. We'll deal with generating the new class from the old enum separately.

Newtonsoft JSON SelectToken to get data from multiple parts of JSON document?

笑着哭i 提交于 2020-01-07 03:46:06
问题 I have JSON that looks like this: (and I do not control this data structure) { "Quest":"To seek the Holy Grail", "FavoriteColor":"Blue", "Mother":{ "name":"Eve", "dob":"1/1/1950" }, "Father":{ "name":"Adam", "dob":"2/1/1950" }, "Siblings":[ { "name":"Abel", "dob":"1/1/1980" }, { "name":"Kain", "dob":"3/1/1981" } ] } I have written code to use the Newtonsoft JSON SelectToken method to look up the names of the mother, father, and siblings and print them on the screen: using System; using

Not allowed to load local resource:

最后都变了- 提交于 2020-01-07 02:29:22
问题 i want to stream online videos ..but i am facing j query error Not allowed to load local resource: ...i find many solution but that all did not work for me. here is my code... controller==>>> public ActionResult PlayVideo(string VidPath) { ViewData["VidPath"] = VidPath; return View(); } view==>>> <video width="500" height="281" controls> <source src="@ViewData["VidPath"]" type="video/mp4"> </video> 回答1: I had the same problem. Whenever I used Server.MapPath or Path.GetFullPath or just

With NewtonSoft, how to create an array of strings with JArray

好久不见. 提交于 2020-01-07 01:49:27
问题 I've got the following code that returns an aggregate exception. I essentially want to create what will be a simple list of strings. JArray jArray = new JArray(); foreach (string id in recipientIds) { var jsonObject = JObject.FromObject( (String)id); jArray.Add(jsonObject); } The above works when id is a class with setters and getters but not when id is a string. 回答1: JToken.FromObject() will work for primitives and collections as well as classes: var jArray = new JArray(recipientIds.Select(s

Newtonsoft JSon Deserialize into Primitive type

独自空忆成欢 提交于 2020-01-06 20:00:33
问题 In my C# program, I am querying a webservice and getting a reply stream back in JSON that looks something like this: {"val":12345.12},{"val":23456.23},{"val":34567.01},... or, with possibly more than 1 value per reply object: {"val1":12345.12,"val2":1},{"val1":23456.23,"val2":3},.... And I have the following code utilizing the Newtonsoft.Json library that parses the stream and performs some action on each parsed object, one at a time: public void ParseReply<T>(StreamReader sr, Action<T>

Newtonsoft JSon Deserialize into Primitive type

本小妞迷上赌 提交于 2020-01-06 19:59:17
问题 In my C# program, I am querying a webservice and getting a reply stream back in JSON that looks something like this: {"val":12345.12},{"val":23456.23},{"val":34567.01},... or, with possibly more than 1 value per reply object: {"val1":12345.12,"val2":1},{"val1":23456.23,"val2":3},.... And I have the following code utilizing the Newtonsoft.Json library that parses the stream and performs some action on each parsed object, one at a time: public void ParseReply<T>(StreamReader sr, Action<T>

Deserialize Google maps Geocode JSON information

非 Y 不嫁゛ 提交于 2020-01-06 18:10:19
问题 I am trying to deserialize google map geocode information. I am close but I am missing something. Here is the JSON output { "results" : [ { "address_components" : [ { "long_name" : "1600", "short_name" : "1600", "types" : [ "street_number" ] }, { "long_name" : "Amphitheatre Pkwy", "short_name" : "Amphitheatre Pkwy", "types" : [ "route" ] }, { "long_name" : "Mountain View", "short_name" : "Mountain View", "types" : [ "locality", "political" ] }, { "long_name" : "Santa Clara County", "short

How to fix Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference in asp.net mvc?

巧了我就是萌 提交于 2020-01-06 16:14:07
问题 I get the following exception in my system.This system worked properly. But suddenly got and exception. I tried doing debugging. But I couldn't find the anything. This is about a profile picture upload. I did some removing of code and I got the error. But then I again add those codes but nothing happen. I tried some solutions in the internet but didn't work. I'm new to this work so please help me if you can. I tried removing some of the codes then I got an error saying invalid operation. How

C# / Json.net / how can i deserialize the message?

别等时光非礼了梦想. 提交于 2020-01-06 14:16:34
问题 please help me on what i need to do next? i need this message to be inside their dedicated strings but i got no idea how to do it also how about using a dictionary? the message that i receive is this.. its inside a string called sServerResponse {"pcname": "Kat", "pause": [], "ip": "192.168.1.100", "paused": 0, "services": [], "session": "", "shop": [], "end": 0, "used": 0, "start": 0, "timeup": 0, "follow": "sui", "consq": {"1": "basic", "3": "rounding", "2": "minimum"}, "stas": 0, "price": 0