3

I'm trying to parse simple json to dynamic object in Windows phone 8. I'm using Newtonsoft.JSON library with this code:

dynamic response = JObject.Parse(responseText);
string streamRequestUrl = response._links.streams;

I can that _links are present there enter image description here But when I try to read it I get Microsoft.CSharp.RuntimeBinder.RuntimeBinderException. How to get _links property value out of it?

Sly
  • 15,046
  • 12
  • 60
  • 89
  • Have you tried it without the debugger enabled? I have a similar issue, works at first after creating the solution, then stops working after a while, if I copy to a new solution it works again. If I run it without the debugger it always works http://stackoverflow.com/questions/20487305/runtimebinderexception-while-using-newtonsoft-json-with-dynamic-after-installing – TimothyP Dec 11 '13 at 04:56

3 Answers3

1

I was hitting something similar in VS 2015. The approach using [] to access the properties works, however if I enable "Just My Code" in Tools > Options > Debugging > General. I was able to use the properties on the dynamic objects as normal e.g. code like: response._links.streams; worked.

See this other post with a similar question

Community
  • 1
  • 1
Justin Slone
  • 451
  • 4
  • 5
0

The value that you're seeing is the ToString() value. What you're looking for is:

response["_links"]

For a full example see: http://james.newtonking.com/projects/json/help/html/ModifyJson.htm

Oren
  • 3,273
  • 2
  • 19
  • 15
0

Yes, you are not alone, I also faced similar issue ( without hangover ;P )

I just modified the file for a space or line and rebuild the entire solution, started working fine in debug mode also...

Happy Holidays!

HydPhani
  • 592
  • 6
  • 13