json.net

Method not found: 'System.Object Newtonsoft.Json.Linq.JToken.ToObject(System.Type)'

送分小仙女□ 提交于 2021-01-28 21:49:59
问题 Our mvc project with json.net running without any problem on every developer except the one with the new windows 8.1 system. How can we find source of the method not found problem ? details of the exception ; [MissingMethodException: Method not found: 'System.Object Newtonsoft.Json.Linq.JToken.ToObject(System.Type)'.] ExtensionMethods.Eval(Object o, String propertyName) in c:\Users\maxSEPHIROTH\Documents\Visual Studio 2012\Projects\LogiSysMvc\LogiSysMvc\ClassLibrary\ExtensionMethods.cs:136

Replace “null” to “0” in json only for int or use Nullable<int>?

久未见 提交于 2021-01-28 15:30:11
问题 I'll try to describe my situation: I have Windows Store App (C#), which receive data from remote data base ( DataBase1 ), and store it in local database in isolated storage ( DataBase2 ). I have single class for all manipulation with data for ex: [Table("Table")] [DataContract] public class Class1 { [PrimaryKey] [Column("id")] [DataMember(Name = "id")] public int Id { get; set; } } This class can take 50+ fields. I use Newtonsoft.Json: var class = JsonConvert.DeserializeObjectAsync<Class1>

MongoDB InsertBatch JObject - Serialization error

时光怂恿深爱的人放手 提交于 2021-01-28 14:07:03
问题 I'm using a .NET application and trying to insert to a MongoDB. I'm using InsertBatch and passing on to it IEnumerable of Newtonsoft.Json.Linq.JObject The error i'm getting: {"Serializer DictionarySerializer<String, JToken> expected serialization options of type DictionarySerializationOptions, not DocumentSerializationOptions."} My code is: private void InsertItemsToMongo(IEnumerable<JObject> list) { MongoClient = new MongoClient("mongodb://localhost:27017"); var myDb = mongo.GetServer()

How to custom deserialize into an object with json.net

牧云@^-^@ 提交于 2021-01-28 11:45:41
问题 I used http://json2csharp.com/ to generate a csharp class that represents my JSON, which worked wonderfully. However, after working with the third party api for a while, I realized that their responses aren't always sending the same type of data. I'm querying their API for Ticket data, and each ticket has a SellPrice. Sometimes they return that SellPrice as a Money object that has a currency (string) and amount (double), and sometimes they send it back as just a double. So I'm trying to find

How to custom deserialize into an object with json.net

自古美人都是妖i 提交于 2021-01-28 11:44:59
问题 I used http://json2csharp.com/ to generate a csharp class that represents my JSON, which worked wonderfully. However, after working with the third party api for a while, I realized that their responses aren't always sending the same type of data. I'm querying their API for Ticket data, and each ticket has a SellPrice. Sometimes they return that SellPrice as a Money object that has a currency (string) and amount (double), and sometimes they send it back as just a double. So I'm trying to find

How to handle object references in JSON document with Newtonsoft Json.NET?

丶灬走出姿态 提交于 2021-01-28 11:39:47
问题 I have a json dataset that comes with standard data fields and reference fields. It looks something like this: [ { "id":1, "name":"Book", "description":"Something you can read" }, { "id":2, "name":"newspaper", "description": { "ref":"0.description" } } ] This is my data model: public class PhysicalObject { [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Default)] public int id; [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Default)] public

Newtonsoft.Json Ignores TypeConverters and/or JsonConverters, regardless of how it they're referenced

倖福魔咒の 提交于 2021-01-28 10:54:28
问题 I have an enum, for example: [JsonConverter(typeof(MyJSONConverter))] public enum MyEnum { a, b, c } I have put the JsonConverter attribute on it. I have defined the converter class: public class MyJSONConverter : JsonConverter<MyEnum> { public MyJSONConverter() { } public override void WriteJson(JsonWriter writer, MyEnum value, JsonSerializer serializer) { serializer.Serialize(writer, value); } public override MyEnum ReadJson(JsonReader reader, Type objectType, MyEnum existingValue, bool

Change key name of data loaded through JsonExtensionData [duplicate]

痞子三分冷 提交于 2021-01-28 10:10:48
问题 This question already has an answer here : How to change all keys to lowercase when parsing JSON to a JToken (1 answer) Closed 3 years ago . I have a JSON resulting from a mix of system data and user entries, like this : { "Properties": [{ "Type": "A", "Name": "aaa", "lorem ipsum": 7.1 }, { "Type": "B", "Name": "bbb", "sit amet": "XYZ" }, { "Type": "C", "Name": "ccc", "abcd": false }] } I need to load it, process it, and save it to MongoDB. I deserialize it to this class : public class

Odata Deserialize in json with Enum DisplayName or EnumMember Value

馋奶兔 提交于 2021-01-28 09:07:44
问题 I have an enum declared in c#. Having Display Name/ EnumMember value annotation and Student Class. I'm using asp.net core 2.2+ version with Odata. [DataContract] Public Class Library { public int Id {get;set;} [DataMember(Name="Book_Name")] public BookNameEnum BookName {get; set;} } [DataContract] JsonConverter[typeof(StringEnumConverter)] public enum BookNameEnum { [Display(Name ="John Wick"), EnumMember(value="John Wick")] JohnWick = 1, [Display(Name ="John Snow"), EnumMember(value="John

nuget dll is used by another process

心已入冬 提交于 2021-01-28 08:23:05
问题 I have the error from below and I'm quite out of ideas how to solve it. Tried the following until now: Clean bin/obj/packages/packages cache Remove manually from csproj and packages files the package and add it afterwards..still error Update Visual Studio 2017 Reinstall Visual Studio 2017 Trace which processes are using a file with name that contains Newtonsoft Copy the solution from another laptop where the builds works just fine Yet, after all from above, I still get: Error NuGet Package