Questions tagged [linq-to-json]

An API to work with JSON objects.

Linq to JSON is part of the Newtonsoft.Json.Linq Namespace. It has been designed to with Linq to enable the querying and creation of JSON objects easily.

38 questions
1
vote
1 answer

JSON.Net - Another data retrieval from a polymorphic json string

Here's what my JSON string looks like: { "?xml" : { "@version" : "1.0", "@encoding" : "UTF-8" }, "DataFeed" : { "@FeedName" : "content", "now" : "2016-10-17T14:11:38.00", "Content" : [{ …
inquisitive_one
  • 1,465
  • 7
  • 32
  • 56
1
vote
2 answers

LINQ to Json data retrieval from polymorphic json

I have a polymorphic json string. Here's what it looks like: { "?xml":{ "@version":"1.0", "@encoding":"UTF-8" }, "DataFeed":{ "@FeedName":"AdminData", "Issuer":[ { "name":"Apple", …
inquisitive_one
  • 1,465
  • 7
  • 32
  • 56
1
vote
2 answers

How to Query and Enumerate complex JSON object using JSON.Net in C#

How can I query (to see if a property exists) and enumerate (the array property) found within a complex JSON object using using JSON.NET in C# ? I am receiving a complex JSON object from an API with a variable number/type of properties. I keep…
Newport99
  • 483
  • 4
  • 21
1
vote
2 answers

LINQ to JSON - Querying an array

I need to select users that have a "3" in their json array. { "People":[ { "id" : "123", "firstName" : "Bill", "lastName" : "Gates", "roleIds" : { "int" : ["3", "9", "1"] } …
inquisitive_one
  • 1,465
  • 7
  • 32
  • 56
1
vote
1 answer

Search text in JSON array in c#

I'm implementing simple search engine.all the data saved as a JSON in text file. My implementing scenario is,If I search word like 'rock' method should return result as list of tag Id's containing 'rock' value.I have been looking for sample codes…
isanka thalagala
  • 456
  • 2
  • 10
  • 22
1
vote
1 answer

Linq to json filtering results with Where clause

I'm new to json. I'm trying to filter json data using linq to json query in C#. I'm trying to retrieve multiple values from json data: string json= @"{ "parts": [ { "attributes": { "Motherboard": "Gigabyte GA-H81M-S2H", …
Rajesh
  • 55
  • 2
  • 11
1
vote
5 answers

Can you call a second constructor without an overload method

So I have a query. It's not really a problem as the code still works but it seems sloppy. I need to have two constructors. public class JsonQuery { const string currentWorkSheet = "GLHTanneryData_CurrentWeek"; const string…
Danrex
  • 1,657
  • 4
  • 31
  • 44
1
vote
1 answer

Returning another library's IEnumerable

I'm implementing a library that parses JSON data into various C# objects using Newtonsoft's LINQ to JSON functions. Apart from the lazy vs. eager approach, is there any impact to passing some other library's IEnumerable vs. dumping it into a List…
user502255
1
vote
3 answers

How to add "undefined" to a JObject collection - where is JToken/JValue.Undefined?

When using Json.NET, I am trying to create a JSON structure dynamically using the "JSON to LINQ" support. In the following, jObject is a JObject and JObject.Add takes (string, JToken). However, I cannot find out how to add either an Undefined or a…
user2864740
  • 60,010
  • 15
  • 145
  • 220
0
votes
2 answers

Get Json property which name contains some string

I have not typical json that I get when request for profile with userName (in example I show what will be if I query with username1. If I query with username2 then property name is…
demo
  • 6,038
  • 19
  • 75
  • 149
0
votes
3 answers

Find the last actual reported quarter

I'm trying to find the last actual reported quarter and it's accompanying display value. The criteria is the @clientsDescription or @displayName has to EPS. Here's what my JSON string looks like: { "?xml": { "@version": "1.0", …
inquisitive_one
  • 1,465
  • 7
  • 32
  • 56
0
votes
1 answer

Linq-To-JSON Walking Up Ancestor Tree To Obtain JProperty for Nearest Parent

I have a fiddle here: https://dotnetfiddle.net/x6u5wH I have two questions but to be fair I'll split them into two posts. I will add a link to the second question at the top of this post once it's posted. Summary If you run the above fiddle, you…
Jazimov
  • 12,626
  • 9
  • 52
  • 59
0
votes
1 answer

LINQ to JSON - NullReferenceException error from a JToken that could be either a JValue or JArray

I'm trying to select all users with a roleId of 4 based on the first element of the array or value. How can I do that? Also, how can I display the roleId? Here's my JSON string: { "?xml" : { "@version" : "1.0", "@encoding" :…
inquisitive_one
  • 1,465
  • 7
  • 32
  • 56
0
votes
1 answer

LINQ to JSON - Setup list from different arrays

I have a polymorphic json string. Here's what it looks like: { "Product" : { "Context" : { "IssuerDetails" : { "Issuer" : { "@clientCode" : "BMTEST-CA", "@companyName"…
inquisitive_one
  • 1,465
  • 7
  • 32
  • 56
0
votes
1 answer

LINQ on polymorphic json to get a comma separated field

I have a polymorphic json string. Here's what it looks like: { "?xml" : { "@version" : "1.0", "@encoding" : "UTF-8" }, "DataFeed" : { "@FeedName" : "complianceCompany", "Companies" : { …
inquisitive_one
  • 1,465
  • 7
  • 32
  • 56