Skip to content

Read json representation into dynamic

JornWildt edited this page Mar 25, 2013 · 1 revision
using System;
using Ramone;

// Create session pointing to service root
ISession Session = RamoneConfiguration.NewSession(new Uri("http://localhost/ramone-testserver"));

// Setup HTTP request
Request req = Session.Bind(CatUrlTemplate, new { name = "Mike" });

// Make actual request - accept JSON as returned media type
using (var resp = req.AcceptJson().Get())
{
  // Access returned data as dynamic built from the JSON data
  dynamic c = resp.Body;
  Console.WriteLine("Cat with name={0} was born on={1:d}.", c.Name, c.DateOfBirth);
}