How do i print out a selected field from my json object without having to create classes for it, at the moment it prints out the whole json object but i just want to print out selected fields for example something like Console.WriteLine(response.venues.name);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace FourSquareTest
{
class Program
{
static void Main(string[] args)
{
using (var webClient = new System.Net.WebClient())
{
var json = webClient.DownloadString("https://api.foursquare.com/v2/venues/search?ll=40.7,-74&query=mcdonalds&client_id=XXXXXXX&client_secret=XXXXXXXX&v=20120101");
// Now parse with JSON.Net
JObject parsed = JObject.Parse(json);
foreach (var pair in parsed)
{
Console.WriteLine("{0}: {1}", pair.Key, pair.Value);
}
}
}
}
}
Try
But I don’t have the library to test, so that’s just based on the documentation.