locked
Json question

    Question

  • I'm trying to figure out how to work with Json in a metro app. I've found some documentation regarding the HttpClient  class, but I haven't turned up the equivalent in the html/js. Any ideas?
    Wednesday, September 21, 2011 5:36 PM

Answers

All replies

  • Use the xhr() function as the equivalent of httpclient and use JSON.parse to transform the results from Json into an object.
    Wednesday, September 21, 2011 5:43 PM
  • If you search in the samples for JSON you will find a few of those applications are using JSON:

    http://code.msdn.microsoft.com/windowsapps/

    Search on Web Client as well.

    You can also search on WebRequest.

    In particular, this sample uses XHR and JSON: http://code.msdn.microsoft.com/windowsapps/Custom-data-sources-example-8a58a0fc

    (look at the BingImageSearchDataSource).


    Jeff Sanders (MSFT)
    Wednesday, September 21, 2011 5:52 PM
    Moderator
  • You're my heros! Downloading code now...
    Wednesday, September 21, 2011 6:02 PM
  • This example is exactly what I'm looking for. I found it unclear in the documentation that xhr could handle json in this way. You might want to consider improving the xhr documentation and marking this example as utilizing json, as a search for json in examples doesn't turn it up.
    Wednesday, September 21, 2011 7:18 PM
  • That's excellent feedback, benWebb. Can you point me at the URL for the misleading docs and I'll see about getting it fixed. Thanks!
    Thursday, September 22, 2011 1:11 PM