json.net

vb.NET Deserialise JSON list into object

穿精又带淫゛_ 提交于 2019-12-12 11:10:57
问题 I've not quite been able to find the exact answer for which I'm looking so thought I'd have a crack at asking the question. I'm currently attempting to deserialise a JSON string into an object in vb.NET using Json.NET; I've done a few before by setting up appropriate Classes and then deserialising the string to an object using the Parent Class and they've worked fine however this one just doesn't seem to break down quite right. An example of the string I'm trying to break down is as follows:

json asmx and that pesky d:

女生的网名这么多〃 提交于 2019-12-12 10:45:33
问题 I have looked through lots of Posts and have not been successful in determining how to get rid of the pesky d in the response coming from my asmx web service, as in {"d":{"Response":"OK","Auth-Key":"JKPYZFZU"}}. This is being created by my class 'public Dictionary UserDevice' by returning the Dictionary object. I would be perfectly happy if the damn thing just wouldn't put it all into the d object! 回答1: You are probably using some kind of framework that automatically wraps your web service

Reading huge integers with Json.NET

好久不见. 提交于 2019-12-12 10:44:45
问题 I've got some json with huge integers, in the order of a few hundred digits. I'd like to parse those as BouncyCastle's BigInteger (https://github.com/onovotny/BouncyCastle-PCL/blob/pcl/crypto/src/math/BigInteger.cs). { "bigNumber":12093812947635091350945141034598534526723049126743245... } So I've implemented a converter, using a contract resolver in the default settings. internal class BigIntegerConverter : JsonConverter { public override void WriteJson(JsonWriter writer, object value,

CamelCase only if PropertyName not explicitly set in Json.Net?

安稳与你 提交于 2019-12-12 10:28:35
问题 I'm using Json.Net for my website. I want the serializer to serialize property names in camelcase by default. I don't want it to change property names that I manually assign. I have the following code: public class TestClass { public string NormalProperty { get; set; } [JsonProperty(PropertyName = "CustomName")] public string ConfiguredProperty { get; set; } } public void Experiment() { var data = new TestClass { NormalProperty = null, ConfiguredProperty = null }; var result = JsonConvert

How to use JSON.NET correctly when deseralizing from embedded DLL?

痞子三分冷 提交于 2019-12-12 10:03:29
问题 I'm writing C# code in Visual Studio. I add the embedded DLL inside the project, I am dynamically loading the assemblies. We use JSON.NET to serialize and deserialize objects with type Context.JobDataObj , which is defined in one of the embedded DLLs, and passing the DLLs between various programs. Unfortunately, whenever I attempt to deserialize, I get the following error: Type specified in JSON 'Context.JobDataObj, HPMContext, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not

more json c# issues

风格不统一 提交于 2019-12-12 09:56:38
问题 This is a continuation of a previous question of mine. The solution worked for what I was trying to do at the time but broke a whole lot of my code. I know it was bad practice not to make sure beforehand but yeah... you live and learn. Anyhoo, here's the Q: an easy way to serialise c# objects What I want to know is: is there any way to get the NewtonSoft Library to handle this stuff? If yes, how? If no, suggestions? What i'm doing is chatting to a RoR3 app using json, now I cant deserialise

Use Json.NET to (de)serialize dictionary in the structure used by DataContractJsonSerializer? [duplicate]

本秂侑毒 提交于 2019-12-12 09:49:17
问题 This question already has answers here : Serialize dictionary as array (of key value pairs) (6 answers) Closed 3 years ago . Is there a way to use Json.NET for (de)serialization but continue to use the dictionary serialization conventions of DataContractJsonSerializer ? In other words, is there a way to read and write JSON in this structure: { "MyDict" : [ { "Key" : "One", "Value" : 1 }, { "Key" : "Two", "Value" : 2 } ] } Using a class like this (with Json.NET attributes): public class

JSON.Net serializer ignoring JsonProperty?

こ雲淡風輕ζ 提交于 2019-12-12 09:33:31
问题 I have the following entity class: public class FacebookComment : BaseEntity { [BsonId(IdGenerator = typeof(ObjectIdGenerator))] [BsonRepresentation(MongoDB.Bson.BsonType.ObjectId)] [JsonProperty("_id")] public ObjectId Id { get; set; } public int? OriginalId { get; set; } public DateTime Date { get; set; } public string Message { get; set; } public string Sentiment { get; set; } public string Author { get; set; } } When this object is serialized to JSON, I want the Id field to be written as

JObject.ToObject<T>() extension method transforms datetime values stored as strings

瘦欲@ 提交于 2019-12-12 09:09:50
问题 When calling ToObject on JObject with a string property, transforms datetime value. class Program { static void Main(string[] args) { var a = JObject.Parse("{\"aprop\":\"2012-12-02T23:03:31Z\"}"); var jobject = a.ToObject<A>(); Console.ReadKey(); } } public class A { public string AProp { get; set; } } The problem is I get my value transformed despite it being a string. The ISO8601 specific characters got skipped: I expect no tranformations to happen and want to be able to do date validation

C# JSON deserialization: can I intercept the deserialization and optionally change the result?

守給你的承諾、 提交于 2019-12-12 08:47:36
问题 We've got some JSON that we are deserializing into a strongly-typed object graph in C#. However, we've got one issue: sometimes there is an "empty" value in the JSON (e.g., empty string) in a property that maps to a boolean value in our model. In our case, we know that 100% of the time, we can translate these "blank" values to Boolean false . However, the JSON deserializers I've tried don't know about this (understandably). I've been trying to find a way to intercept the deserialization of