json.net

JSON Deserialize complex derived object using Newtonsoft JSON.NET [duplicate]

心已入冬 提交于 2019-12-11 19:33:17
问题 This question already has an answer here : Best way to store serialization related info between serialization and deserialization (1 answer) Closed 6 years ago . class Packet { public Action{get;set;} } class Action { string Type; } class ConcreteAction1 : Action { base.Type="ConcreteAction1"; } class ConcreteAction2 : Action { base.Type="ConcreteAction2"; } I receive Packet class which contains various derived class from Action class, by default every ConcreteActions are deserialized as base

vb.net json.net parse results

混江龙づ霸主 提交于 2019-12-11 18:58:12
问题 I would like to get the amount of viewers on an online stream. Right now this stream is online https://api.twitch.tv/kraken/streams/ludendi For reference, the JSON from the above URL looks like this: { "_links": { "self": "https://api.twitch.tv/kraken/streams/ludendi", "channel": "https://api.twitch.tv/kraken/channels/ludendi" }, "stream": { "_id": 9911305984, "game": "The Legend of Zelda: Majora's Mask", "viewers": 3848, "preview": { "small": "http://static-cdn.jtvnw.net/previews-ttv/live

Json.net how to use jsonpath with “$.”

£可爱£侵袭症+ 提交于 2019-12-11 17:57:24
问题 I'm trying to use json.net from json as follows: String JSONString = @"[ { ""category"": ""reference"", ""author"": ""Nigel Rees"", ""title"": ""Sayings of the Century"", ""price"": 8.95 }, { ""category"": ""fiction"", ""author"": ""Still Here"", ""title"": ""Test remove title"", ""price"": 12.99, ""isbn"": ""0-553-21311-3"" } ]"; JObject JSONObject; JSONObject = JObject.Parse(JSONString); String JSONPath = @"$[0].title"; JSONObject.SelectToken(JSONPath); Getting Exception: ST.Acxiom.Test

Newtonsoft Json converter for json with filters

感情迁移 提交于 2019-12-11 17:39:38
问题 I am writing converter for json like this: { "datatable": { "data": [ [ "A85002072C", "1994-11-15", 678.9 ] ], "columns": [ { "name": "series_id", "type": "String" }, { "name": "date", "type": "Date" }, { "name": "value", "type": "double" } ] }, "meta": { "next_cursor_id": null } } At the moment my converter looks like this: public class AbsToModelConverter : JsonConverter { public override bool CanConvert(Type objectType) { return objectType.Name.Equals("AbsFseModel"); } public override

missing a using directive or an assembly reference issue after deploying an ASP.NET “Website”

假如想象 提交于 2019-12-11 17:33:34
问题 So I have an ASP.NET website, which works great on my machine. But when I deployed it on web host server, its giving me an error saying: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly

JSON.NET - deserialize JSON into object, which class type is in inner field

落爺英雄遲暮 提交于 2019-12-11 17:31:11
问题 Usually we deserialize using JSON.NET by this code JsonConvert.DeserializeObject<CLASS TYPE> (text, settings); Imagine, that we have such JSON request: { "command" : "register_user", "params" : { "@c" : "register_params", "name" : "sdfsd", "email" : "sdfsd@ddkdk", "password" : "JDFffJJJd" } } How could we automatically detect that we need deserialize "name", "email" and "password" fields into one register_params object using JSON.NET? 回答1: Using the TypeName value "$type". I've written two

Nested list JSON .NET

笑着哭i 提交于 2019-12-11 16:57:02
问题 I am currently trying to accept a POST request to a .NET Core Web API endpoint that accepts the following model: public class OrderPost { [Required] public string DeliveryStreet { get; set; } public string DeliveryBuilding { get; set; } [Required] public string DeliveryCity { get; set; } [Required] public string DeliveryProvince { get; set; } [Required] public string DeliveryPostalCode { get; set; } [Required] public string CardName { get; set; } [Required] public string CardNumber { get; set

USQL JsonTextWriter.Writevalue is throwing error “The type 'Uri' is defined in an assembly that is not referenced”

我只是一个虾纸丫 提交于 2019-12-11 16:17:33
问题 I have a custom outputter for my USQL job which basically writes json output in a file using JsonTextWriter. I get following error when I try to compile error: "The type 'Uri' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'." at line: 60, column 20 Line number 60 is writer.WriteValue("Test"); I basically get this error for all the lines where I am doing WriteValue Here is my

Problem with Json Deserialization of html string using Json.Net

泄露秘密 提交于 2019-12-11 15:53:52
问题 I'm not an expert with json, actually I started last week working with it and I found myself having trouble trying to get map the following Json into a class. S far I have copy the data from the browser into different Json files (isolate data to see the problem) and I realize that the property Config mess the deserialization process. If I (1) grab the entire data and (2) put it into a file and (3) add the extension .json and then later (4) just erase the Config property, everything works like

Does NuGet packages have versions in Azure DevOps Nuget Tool Installer task?

ε祈祈猫儿з 提交于 2019-12-11 15:50:14
问题 This is a visual studio 2015, dotnet framework 4.6.1 application. I have tried to build and deploy from Azure DevOps onto Azure cloud. The error on deployment is "NewtonSoft.json.dll missing". So when i replace the Azure DevOps artifacts with the visual studio build dll's and files the application works. This is UAT test i'm performing where in the build pipeline i have used NuGet Packages task. The final artifacts generated contains newtonsoft file but i crosschecked it is not same size as