json

Rails app crashes and burns when sending a GET request with Content-Type header set

I have created a rails application that has a simple RESTful json API. This has worked for a while, but now we have run into a problem. The javascript framework that makes requests adds a "Content-Type" header to all requests . . . including GET requests. It sets the header to "application/json" and causes the rails app to crash and burn...

Howto parse json with smarty?

Hi, In Smarty, is there a standard function or an easy way to parse json from an array, as json_encode() does in php? Actually It seems there is not in smarty documentation but wanted to ask anyways. Thanks, Sinan. ...

Post a JSON object to server using PHP & Jquery

I have a JSON object: [{"song_id":"17382","title":" Revolution","song_viewed":"6","FK_genre_id":"11","artist_id":"190","artist_name":"Crematory","album_id":"1507","album_name":"Revolution"},{"song_id":"17377","title":"Reign Of Fear","song_viewed":"6","FK_genre_id":"11","artist_id":"190","artist_name":"Crematory","album_id":"1507","album...

How can I stop my ASP.NET webservice from returning xml data?

Hi folks, I've got a simple ASP.NET webservice. I'm wanting to return a string of json as the result. By default, my webservice is wrapping my json result in some xml. eg. <?xml version="1.0" encoding="utf-8"?> <string xmlns="http://webservice.streetadvisor.com/"&gt;{.... json result in here ... }</string> Booo. Is there any way i...

When I hardcode an ASP.NET HTTP-StatusCode to 401, I keep getting bounced to the login page?

Hi folks, I've got an API setup. When the user provides an invalid/missing API key, I'm trying to set the Response.StatusCode to 401, something keeps bouncing me to my login page. It's an API ... so I don't want that. I wish to send them the json error message with the code being 401. url for this sample api is : /api/search/foo?apike...

IE8 native JSON.parse bug causes stack overflow

TL;DR: Adding any non-built-in functions to Array.prototype AND Function.prototype will cause the IE8 native JSON parser to get a stack overflow when parsing any JSON that contains an array, but only when you also pass a reviver function into JSON.parse(). This started out as a question, but I answered my own original question, so now I...

Sending multiple parameter(hash table ie. NSDictionary) to a ruby on rails server

Hi, I have been trying to create an NSDictionary of the parameters in my iPhone application and want to send it across(through a POST HTTP request, there are some other parameters also in the request) to a ruby on rails server to be consumed by a ruby method which takes a hash table as arguments. Do I need to serialize the NSDictionary...

Unpredictable hierarchy in JSON object...

When building an ajax application, I normally prefer fetching remote data in JSON format. However, when the hierarchy is unpredictable (specifically geocoding responses from Google Maps API), it is tempting to go with XML format because the DOM method getElementsByTagName will get the data wherever it is in the hierarchy. Assuming there ...

How does crossdomain data access work?

I'm using JQuery to make a JSON request to access data on a private server. I've noticed however that I get this message when attempting to access the data: Security Error: Content at xxxxxxx may not load data from xxxxxxx. Looking at the JQuery reference I see it's accessing: http://api.flickr.com/services/feeds/photos%5Fpublic....

How do I convert a c# two-dimensional array to a JSON object?

If I have a two-dimensional array in C# - how can I convert it into a JSON string that contains a two dimensional array? eg. int[,] numbers = new int[8,4]; JavaScriptSerializer js = new JavaScriptSerializer(); string json = js.Serialize(numbers); gives a flat one-dimensional array in a JSON object. The Microsoft documentation states:...

Parsing JSon array in JQuery

Hi, I'm trying to get the hand on JQuery and Json using an Asp.Net webservice. The Webservice returns this result: { MyResult: { Ticket: { "Author": "rd", "CssClass": "RED", "ExpirationDateTime": "2009-08-16T16:55:43.577+02:00", "id": "38", "Message": "We are going ...

Encrypting JSON in Google Gears Workerpool

Hello, I need to encrypt JSON (stringified) data in a Google Gears Workerpool. So far, any implementation I tried either makes the Gears Workerpool bug out, or gives me unwanted encrypted strings. For example: DES encryption (can't post URL due to account restrictions) This works brilliantly for most applications, except after encrypti...

how do i use php to read an external file and put insides into variables?

I had no idea to correctly form the title of this question, because I don't even know if what I'm trying to do has a name. Let's say I've got an external file (called, for instance, settings.txt) with the following in it: template:'xaddict'; editor:'true'; wysiwyg:'false'; These are simple name:value pairs. I would like to have php ...

Rails, Extjs and SQL Server

So I'm running Extjs on top of Rails 2.3.3 against a SQL Server DB. I'm able to pull data from the DB and display it, but I'm unable to create, update or destroy. Oddly enough, it's not throwing console or any other errors on attempted updates or deletes -- it simply fails. On create, an InvalidStatement error gets thrown, probably r...

How do I send deep JSON objects to an Action?

In my web app I have a dynamically generated form that I use to create a JSON object to pitch back to an Action. As seen here: function getConfigItemWithValidators() { log.info("getConfigItemWithValidators()"); var oConfigItem = { "Name": $("#txtName").html(), "InputFileCellIndex": $("#inpFi...

What's the best way of passing a .NET System.DateTime using JSON so that cient-side javascript can construct a javascript Date object?

I'm building the JSON string "by hand" server-side. Should I Convert.ToString(System.DateTime.Milliseconds) on the server-side and use javascript Date.setTime(milliseconds) on the client side? ...

Explanation and usage of JSONP

What is JSONP, why is it needed, and what are some real world examples of it's usage. ...

Hierarchical data output from App Engine Datastore to JSON?

I have a large hierarchical dataset in the App Engine Datastore. The hierarchy is preserved by storing the data in Entity groups, so that I can pull a whole tree by simply knowing the top element key like so: query = db.Query().ancestor(db.get(key)) The question: How do I now output this data as JSON and preserve the hierarchy? Googl...

Tempdata in ASP.Net MVC with JSON Request

Hi, I have an ActionResult that sets TempData to be an object. The page that is rendered contains a button, that launches a JSON request to the same controller. (For jqGrid population). The TempData on the JSON Request is null - why does this happen? Even more bizarrely, if I had a button that posts to the same controller, and I cli...

Generate JSON object with transactionReceipt

Hi, I've been the past days trying to test my first in-app purchse iphone application. Unfortunately I can't find the way to talk to iTunes server to verify the transactionReceipt. Because it's my first try with this technology I chose to verify the receipt directly from the iPhone instead using server support. But after trying to sen...