json

jQuery and parsing JSON in the callback

I'm using jQuery to call an asmx and return some data. I'm making the call like this function getRequestInfo(event) { var id = $('#<%= RequestDaysId.ClientID %>').val(); var formattedId = "{'id': '115'}"; $.ajax({ type: "Post", url: "services/VacationServices.asmx/GetVacationInfo", ...

Best way to convert JSON data to an object in javascript

I am currently using eval in Javscript to convert JSON data returned from the server into an object. eval ("myObject="+data); I've been told that eval is 'evil' and can open up big security problems. I'm wondering - is using eval to convert JSON data to an object the accepted practice? Or is there a better way? Thanks, ...

How to display JSON data in a select box using jQuery?

Hi all, this is my JSON data: {"ACT":"Australian Capital Territory","NSW":"New South Wales","NT":"Northern Territory","QLD":"Queensland","SA":"South Australia","TAS":"Tasmania","VIC":"Victoria"} How to display this JSON data in a selectlist? ...

Python JSON New York Times API

Hi Everyone, Really new to Python and getting data from the web, so here it goes. I have been able to pull data from the NYT api and parse the JSON output into a CSV file. However, depending on my search, I may get the following error when I attempt to write a row to the CSV. UnicodeEncodeError: 'charmap' codec can't encode charac...

How can i return a form using ajax into a view ASP.Net MVC

Hi All, i just started building a small test app to help me learn MVC. i have a view that displays user comments. Under each comment i would like to have a reply action link. Clicking on the link should return a small form for adding a comment directly above the reply link. What is the general approach for this? I'm imaging the form wou...

VB.NET problem converting DataTable to JSON

Ok so I'm trying to use the JavaScriptSerializer to work with this code. However it crashes when it reaches the last line; Dim json As New String(sr.Serialize(dt)) I get this error message; A circular reference was detected while serializing an object of type 'System.Reflection.Module'. I would really appreciate any insights...

decoding json value into a php variable

When I pass the results from getJSON to parseInfo() function just like the one below, is it possible to get results back into a php variable so that I could put the latter through another php function. $.getJSON('getinfo.php', { id:id }, parseInfo); function parseInfo(data) { <?php $some_var = json_decode(data); funct...

How to post json object in web service

Dear All, Can any one help me please that how to post Json object to web service using c#? Actually I am trying to verify an App Store Transaction Receipt in C#. follow this link to have an enough idea. http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conceptual/StoreKitGuide/VerifyingStoreReceipts/VerifyingS...

Should I use Json or Xml in Silverlight

I'm communicating with several services from a SL component using both TCP sockets & HTTP web requests and we are discussing what (data) format to use - JSON or XML. I'm wondering what others have choosen and why? Cheers AWC ...

how to format mysql results to json php

hello mysql table ID >> Name >> Salary $row_set << database table information. my problem is when i use json_encode($row_set); the output will be something like this: [{"0":"1","ID":"1","1":"x","Name":"x","2":"12345","Salary":"12345"}] i want the results to be something like this [{"ID":"1","Name":"x","Salary":"12345"}] ho...

Returning Entity Data Model Entities as JSON data

I noticed people wrote about this circular reference problem quite a bit before but no solution was ever posted. I'm talking about this error: "A circular reference was detected while serializing an object of type 'DocInvoice.Models.Clients'." Has anyone tried serializing it to JSON with Json.NET library? If I have Linq to entities q...

From DataTable in C# .NET to JSON

I am pretty new at C# and .NET, but I've made this code to call a stored procedure, and I then want to take the returned DataTable and convert it to JSON. SqlConnection con = new SqlConnection("connection string here"); SqlDataAdapter da = new SqlDataAdapter(); SqlCommand cmd = new SqlCommand("getDates", con); SqlParame...

AJAX: Waiting for response?

I'm using global variables to pass around a response from a AJAX call: window.response = null; // most recent response from XMLHttpRequest // the callback function for XMLHttpRequest function userObjFromJSON() { if (this.readyState == 4) { var json = eval('(' + this.responseText + ')'); window.response = json; }...

AJAX: Check if a string is JSON?

My JavaScript sometimes crashes on this line: var json = eval('(' + this.responseText + ')'); Crashes are caused when the argument of eval() is not JSON. Is there any way to check if the string is JSON before making this call? I don't want to use a framework - is there any way to make this work using just eval()? (There's a good reas...

Parse JSON as easily as XML can be in Python 3

In Python 3 it is easy to find a given tag in an XML file via etree. Using JSON, I've found there isn't a function to do that. Is there a library that does so efficiently? Is it worth my time to have a tree constructed from some JSON? I'm having to use woeid = data["places"]["place"][0]["woeid"] where with XML I could simply use tree.f...

Problem with StringBuilder and JSON

I am trying to execute this code in C#.NET to turn an SQL table into a string with proper JSON; json.AppendFormat("Places: [{{\"AvgDate\": \"{0}\"},\"MarkerID\": \"{1}\"}]", reader["AvgDate"], reader["MarkerID"]); However it won't let me use the comma separation between the {0} and {1} indexes. The following works fine; json.AppendFo...

What is the difference between these two ways of returning a JSON object?

I'm playing around with the jQuery Week Calendar and am trying to get this to work, but I can't figure out why this is throwing an error. The calendar has a method that returns a list of events to populate itself with. The method (which uses preset events for demo purposes) looks like this: function getEventData() { var year = n...

jQuery to parse JSON

I'm trying to parse the JSON returned from SocialMention. Here's an example of what the JSON looks like: {"title":"Social Mention","count":100,"items":[{"title":"RT @Jason_IIATMS: More Damon-isms that'll make you wanna puke: \"Let's hope the Chinese are right when they say this is the year of the tiger!\"","description":"","link":"htt...

Json.NET - How to serialize a class using custom resolver

I want to serialize this class: public class CarDisplay { public string Name { get; set; } public string Brand { get; set; } public string Year { get; set; } public PictureDisplay[] Pictures { get; set; } } public class PictureDisplay { public int Id { get; set; } public string SecretKey { get; set; } publ...

Should I use XML or JSON as a data format in Android Applications?

I'm starting to develop an application for Google Android and heavily relying on a web API that can deliver data in a restful way via json or xml. I now have to decide which library to choose. I saw that google includes org.json classes in the API but haven't tested them yet. How are your experiences? What library/API should I use an...