json.net

Parse json with different types value (Newtonsoft.Json)

泄露秘密 提交于 2020-01-06 13:37:12
问题 Help me parse the json with Newtonsoft.Json . { "_id": 160, "location": { "type": "Point", "coordinates": [43.59043144045182, 39.72119003534317] }, }, { "_id": 161, "location": { "type": "LineString", "coordinates": [ [43.58780105200211, 39.719191789627075], [43.58817794899264, 39.719465374946594] ] }, }, { "_id": 152, "location": { "type": "Polygon", "coordinates": [ [43.590524759627954, 39.71930980682373], [43.590474249766544, 39.71926689147949], [43.59043151061995, 39.71934735774994], [43

asp.net json.net parse results

故事扮演 提交于 2020-01-06 10:53:05
问题 I´m not familiar with JSON data parsing. So far, this is what I´ve come up to through web research: data to parse: https://api.twitch.tv/kraken/streams/ I´m trying to use the JSON.NET/VB.NET framework to do so: Imports Newtonsoft.Json Imports Newtonsoft.Json.Linq '(inside a function) Dim json As JObject = JObject.Parse("https://api.twitch.tv/kraken/streams/") strResult As String = json.SelectToken("streams").SelectToken("game") It´s returning me an error message, and I´m sure I don´t have the

OutOfMemory Exception with Streams and BsonWriter in Json.Net

寵の児 提交于 2020-01-06 07:25:45
问题 I'm having a problem using Json.net and creating a large Bson file. I have the following test code: Imports System.IO Imports Newtonsoft.Json Public Class Region Public Property Id As Integer Public Property Name As String Public Property FDS_Id As String End Class Public Class Regions Inherits List(Of Region) Public Sub New(capacity As Integer) MyBase.New(capacity) End Sub End Class Module Module1 Sub Main() Dim writeElapsed2 = CreateFileBson_Stream(GetRegionList(5000000)) GC.Collect(0) End

Serialize and deserialize JSON object from separate classes without need to have stand-alone class?

冷暖自知 提交于 2020-01-06 06:35:21
问题 Is it possible to form an object from two classes and then serialize it to JSON, and when deserialize it back be able to get those two objects. say I have: an object of Student and a List<Course> is it possible to combine these two objects in one JSON object. I need this because building up a class for every JSON object would be very exhausting in the project I'm working on! 回答1: Is it possible to form an object from two classes and then serialize it to JSON Yes it is possible to do this just

Filter json properties by name using JSONPath

孤街醉人 提交于 2020-01-06 06:01:09
问题 I'd like to select all elements with a certain match in the name of the property. For example, all the properties whose name starts with 'pass' from this json: { "firstName": "John", "lastName" : "doe", "age" : 50, "password" : "1234", "phoneNumbers": [ { "type" : "iPhone", "number": "0123-4567-8888", "password": "abcd" }, { "type" : "home", "number": "0123-4567-8910", "password": "fghi" } ] } Would result something like this: [ "1234", "abcd", "fghi" ] I don't want filter by values, only by

NewtonSoft JSON Loop Through JArray

不想你离开。 提交于 2020-01-06 05:47:16
问题 I'm attempting to loop through a JArray and I'm getting msg is not declared error inside my for/next loop. My JSON is formatted like this... { "messages":[ { "id": 123456789, "sender_id": 1236547890, "replied_to_id": null, "created_at": "2017/09/28 15:49:20 +0000", "network_id": 554477, "message_type": "update", "sender_type": "user", "url": "https://www.example.com", "web_url": "https://www.example.com/123456789", "group_id": 7418529, "body": { "urls": [ "https://www.facebook.com/blah/blah

Does ASP.NET Core Support JSON Web Signatures for RESTful Web APIs?

谁都会走 提交于 2020-01-06 04:08:06
问题 I have read some excellent tutorials on using JSON Web Tokens with ASP.NET Core to authenticate requests to a REST API, however I can find no documentation on whether the more general JSON Web Signature (rfc7515) is supported for use with REST API Definitions to tamper-protect the contents of requests. For example, the following Controller allows a simple POST request whereby a JSON serialized 'CreateRequest' object is submitted to the API and handled: [Produces("application/json")] [Route(

Json.Net Deserialization of Complex Objects - Base Class that Contains a Base Class as a Property

ぐ巨炮叔叔 提交于 2020-01-06 03:02:08
问题 I have been attempting to resolve this issue for several hours. I have tried many approaches and read many posts. I can't seem to find a resolution. I have an object hierarchy whereby I have derived types that contain another derived type. I am using Json.Net's TypeNameHandling setting. I have it set to Auto on both serialization and deserialization. The resulting JSON is: "[\r\n {\r\n \"$type\": \"Common.Monitors.HeartbeatMonitor, Common\",\r\n \"ClassName\": \"HeartbeatMonitor\",\r\n \

Create class parse from json to c#

回眸只為那壹抹淺笑 提交于 2020-01-06 02:24:14
问题 I've created a class to parse from json to C# with json.net library, but may be my class has something wrong. My Json code: { "data": [ { "category": "Health/beauty", "category_list": [ { "id": "144873802247220", "name": "Cosmetics & Beauty Supply" } ], "name": "T2Perfume", "created_time": "2013-06-19T12:22:46+0000", "id": "493082927378290" }, { "category": "Company", "category_list": [ { "id": "2200", "name": "Company" } ], "name": "H\u1ed9i th\u1ea3o Vi\u1ec7t - Hoithao.vn", "created_time":

Why is my JSON Response not being Deserialized on my Client into the same Generic List Type as the Origin IEnumerable Type on the Web API server?

孤人 提交于 2020-01-06 01:30:08
问题 If I understand Ufuk Hacıoğulları here I can simplify this code: using (var webResponse = (HttpWebResponse)webRequest.GetResponse()) { if (webResponse.StatusCode == HttpStatusCode.OK) { var reader = new StreamReader(webResponse.GetResponseStream()); string s = reader.ReadToEnd(); var arr = JsonConvert.DeserializeObject<JArray>(s); if (arr.Count <= 0) break; foreach (JObject obj in arr) { id = obj.Value<int?>("Id") ?? 0; var _deptId = obj.Value<int?>("deptId") ?? 0; var _subdeptId = obj.Value