How to make sure that string is valid JSON using JSON.NET
I have a raw string. I just want to validate whether the string is valid JSON or not. I’m using JSON.NET. 12 Answers 12
I have a raw string. I just want to validate whether the string is valid JSON or not. I’m using JSON.NET. 12 Answers 12
I need to write the following data into a text file using JSON format in C#. The brackets are important for it to be valid JSON format. [ { “Id”: 1, “SSN”: 123, “Message”: “whatever” }, { “Id”: 2, “SSN”: 125, “Message”: “whatever” } ] Here is my model class: public class data { public … Read more
I’m trying to parse some JSON data from the Google AJAX Search API. I have this URL and I’d like to break it down so that the results are displayed. I’ve currently written this code, but I’m pretty lost in regards of what to do next, although there are a number of examples out there … Read more
Things I’ve tried after searching: in Web.Config put a binding on the old version: <dependentAssembly> <assemblyIdentity name=”Newtonsoft.Json” publicKeyToken=”30ad4fe6b2a6aeed” culture=”neutral” /> <bindingRedirect oldVersion=”0.0.0.0-6.0.0.0″ newVersion=”6.0.1.0″ /> </dependentAssembly> Edit my .csproj file to make sure there is only one Newtonsoft reference <Reference Include=”Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL”> <HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> <SpecificVersion>False</SpecificVersion> <Private>True</Private> </Reference> Search my computer for every Newtonsoft.Json.dll and … Read more
I am getting the Error System.IO.FileLoadException : Could not load file or assembly ‘Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) for my CI build Solution which I tried <dependentAssembly> <assemblyIdentity name=”Newtonsoft.Json” publicKeyToken=”30ad4fe6b2a6aeed” culture=”neutral” /> <bindingRedirect oldVersion=”0.0.0.0-6.0.0.0″ newVersion=”6.0.0.0″ /> … Read more
My problem is that I wish to return camelCased (as opposed to the standard PascalCase) JSON data via ActionResults from ASP.NET MVC controller methods, serialized by JSON.NET. As an example consider the following C# class: public class Person { public string FirstName { get; set; } public string LastName { get; set; } } By … Read more
I have the following variable of type {Newtonsoft.Json.Linq.JArray}. properties[“Value”] {[ { “Name”: “Username”, “Selected”: true }, { “Name”: “Password”, “Selected”: true } ]} What I want to accomplish is to convert this to List<SelectableEnumItem> where SelectableEnumItem is the following type: public class SelectableEnumItem { public string Name { get; set; } public bool Selected { … Read more
I started to use Json.NET to convert a string in JSON format to object or viceversa. I am not sure in the Json.NET framework, is it possible to convert a string in JSON to XML format and viceversa? 13 Answers 13
I happily use the Newtonsoft JSON library. For example, I would create a JObject from a .NET object, in this case an instance of Exception (might or might not be a subclass) if (result is Exception) var jobjectInstance = JObject.FromObject(result); now I know the library can deserialize JSON text (i.e. a string) to an object … Read more
I am trying to extend the JSON.net example given here http://james.newtonking.com/projects/json/help/CustomCreationConverter.html I have another sub class deriving from base class/Interface public class Person { public string FirstName { get; set; } public string LastName { get; set; } } public class Employee : Person { public string Department { get; set; } public string JobTitle … Read more