json

How to correct character encoding in IE8 native json ?

I am using json with unicode text, and having a problem with the IE8 native json implementation. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script> var stringified = JSON.stringify("สวัสดี olé"); alert(stringified); </script> Using json2.js or FireFox native json, the alert() string is the same as...

How can I create a Searchstring for a Google AJAX Search API?

Hello, i have this code to get the search resutls from the api: querygoogle.php: <?php session_start(); // Here's the Google AJAX Search API url for curl. It uses Google Search's site:www.yourdomain.com syntax to search in a specific site. I used $_SERVER['HTTP_HOST'] to find my domain automatically. Change $_POST['searchquery'] to ...

Jquery return multiple values in ajax call

I have a jquery post function that returns a response on success after the click of a div. However, I would like to return multiple variables on success. Do I have to use JSON, and if so, is it possible to integrate it into the $.ajax function after success? $.ajax({ type: "POST", data: "action=favorite&username=" + username + "&t...

Call server side method from JSON

How to call a method on a server side from JSON. Below is the code I am using SERVER SIDE: [WebMethod] private void GetCustomer( string NoOfRecords) { string connString = "Data Source=Something;Initial Catalog=AdventureWorks;Trusted_Connection=True;"; SqlConnection sCon = new SqlConnection(connString); SqlDataAdapter da = ...

Override to_json in Rails 2.3.5

Update: This issue was not properly explored. The real issue lies within render :json. The first code paste in the original question will yield the expected result. However, there is still a caveat. See this example: render :json => current_user is NOT the same as render :json => current_user.to_json That is, render :json will no...

How to build a JSON response made up of multiple models in Rails

First, the desired result I have User and Item models. I'd like to build a JSON response that looks like this: { "user": {"username":"Bob!","foo":"whatever","bar":"hello!"}, "items": [ {"id":1, "name":"one", "zim":"planet", "gir":"earth"}, {"id":2, "name":"two", "zim":"planet", "gir":"mars"} ] } However, my User an...

Why Is my json-object from AJAX not understood by javascript, even with 'json' dataType?

My js code simply gets a json object from my server, but I think it should be automatically parsed and turned into an object with properties, yet it's not allowing access properly. $.ajax({ type: 'POST', url: '/misc/json-sample.js', data: {href: path}, // THIS IS THE POST DATA THAT IS PASSED IN; safe2ignore. ...

Rails 3: What is the proper way to respond to REST-ful actions with JSON in rails?

Hello SO. I'm trying to make an API for my rails application using JSON responses to RESTful resource controllers. This is a new experience for me, so I'm looking for some guidance and pointers. To start things off: In a rails application, what is the "proper" way to respond with JSON to REST-ful controller methods? (create, update, d...

How to design a streaming API

I want to design a web svc that will push out data as they arrive at the backend server. Something like a twitter streaming API. I want to use the .Net platform The consumers can use json and javascript events to be notified when new stuff is in the pipe. How can I design something like this? ...

iPhone: Best Method for Passing Data to and from a Server

I am developing an iPhone application that downloads data from a website. The website database is implemented in SQL and the site itself uses the classic ASP interface. I am unsure as to which method would be best for transferring data to and from the server. Both JSON and SOAP require XML processing and I'm not sure how that affects p...

Serialize or json in PHP?

So I need to encode an array in PHP and store it in plain text in MySQL database, my question is should I use serialize() or json_encode()? What are the advantages and disadvantages of each of them? I think either of them would do in this situation. But which one would you prefer and why? If it is for something other than an array? ...

Jquery Multiple ajax call

I have a listed navigation with letters and i am trying to call the actors and directors from different json files when the user clicked a letter. I used 2 ajax calls to get the data from actor.php and director.php. It works fine on my local machine, but only the first one works on server. How can i make each ajax calls working? $(docu...

How do I view this in an easy format to read? (JSON)

https://search.twitter.com/search.json?q=doug How do I read this like VIEW SOURCE, so that I know what I'm looking at? Is there a website that can prettify it for me? BTW, I use python ...

How to prevent direct access to my JSON service?

I have a JSON web service to return home markers to be displayed on my Google Map. Essentially, http://example.com calls the web service to find out the location of all map markers to display like so: http://example.com/json/?zipcode=12345 And it returns a JSON string such as: {"address": "321 Main St, Mountain View, CA, USA", ...} ...

Unit Test json output in Zend Framework

The Zend Tutorial lists many assertions to check the output generated by a request. http://framework.zend.com/manual/en/zend.test.phpunit.html But they all seem to assume that the output is html. I need to test json output instead. Are there any assertions helpful to check json, or is there at least a generic way to make assertions ag...

How to get JSON objects value if it's name contains dots?

I have a very simple JSON array (please focus on "points.bean.pointsBase" object): var mydata = {"list": [ {"points.bean.pointsBase": [ {"time": 2000, "caption":"caption text", duration: 5000}, {"time": 6000, "caption":"caption text", duration: 3000} ] } ] }; // Usually we ...

jQuery AutoComplete Plugin not working for JSON Response (sValue.substring is not a function)

I'm trying to use the autocomplete plugin for jQuery (this one http://docs.jquery.com/Plugins/Autocomplete). My server is returning JSON string, which I'm trying to process on the client via AutoComplete plugin's 'parse' and 'formatItem' parameters, like so: $(document).ready(function() { $('.searchBox input.textbox').autocomplete('...

How to call a php controller method using jquery?

I am developing a web application and i am integrating jquery in it... Now looking for ajax calls with jquery to my controller function.... jquery.ajax() would be useful i think so... But how to call my controller method.... $.ajax({ type: "POST", url: "http://localhost/codeigniter_cup_myth_new/index.php/libraryControll...

Json Jackson deserialization without inner classes

Hi everyone, I have a question concerning Json deserialization using Jackson. I would like to deserialize a Json file using a class like this one: (taken from http://wiki.fasterxml.com/JacksonInFiveMinutes) public class User { public enum Gender { MALE, FEMALE }; public static class Name { private String _first, _last; ...

JSON String formed improperly using JayRock in .Net

I am trying to return a JSON object from an aspx page using JayRock.JSON. My code for writing it out is this: using (JsonTextWriter writer = new JsonTextWriter(Response.Output)) { writer.WriteStartObject(); for (int i = 0; i < rdr.FieldCount; i++) { writer.WriteMember(rdr.GetName(i).ToString()); ...