Skip to content

Instantly share code, notes, and snippets.

@simplement-e
Forked from anonymous/other.cs
Created April 30, 2014 03:12
Show Gist options
  • Save simplement-e/b5854183a30a3967c597 to your computer and use it in GitHub Desktop.
Save simplement-e/b5854183a30a3967c597 to your computer and use it in GitHub Desktop.
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
[JsonObject()]
public class Unnamed
{
public Team team { get; set; }
public override string ToString()
{
return string.Format("team = {0}", team);
}
}
[JsonObject("team")]
public class Team
{
[JsonProperty("international_date")]
public bool InternationalDate { get; set; }
[JsonProperty("is_coed")]
public bool IsCoed { get; set; }
[JsonProperty("team_name")]
public string TeamName { get; set; }
public override string ToString()
{
return string.Format("{0};{1};{2}", InternationalDate, IsCoed, TeamName);
}
}
class Program
{
static void Main(string[] args)
{
string s = "[{team: {international_date: false,is_coed: false,team_name: 'foo bar'} }, { team: { international_date: false, is_coed: false,team_name: 'foo bar'}}]";
Unnamed[] un = Newtonsoft.Json.JsonConvert.DeserializeObject<Unnamed[]>(s);
foreach (var r in un)
Console.WriteLine(r);
Console.ReadLine();
}
}
}
@nguyenthu267
Copy link

Hai do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment