json

jQuery won't read JSON response (using $.post)

Hi All, In a nutshell, I have a form, which upon submissions, sends data to a serverside script to process a function, return data in JSON format for me to parse and spit back out onto the page. jQuery sends data to "createUser.php" via the $.post method $("#create_submit").click(function(){ $.post("/createUser.php", { c...

Unable to decode JSON stripslashed String?

Does anyone know why this happens? var_dump(json_decode(stripslashes(json_encode(array("O'Reiley"))))); // array(1) { [0]=> string(8) "O'Reiley" } var_dump(json_decode(stripslashes(json_encode(array("O\'Reiley"))))); // NULL Are ' used at all by the JSON functions? ...

ActiveRecord serialize using JSON instead of YAML

I have a model that uses a serialized column: class Form < ActiveRecord::Base serialize :options, Hash end Is there a way to make this serialization use JSON instead of YAML? ...

JSON exception while calling getJSONObject

IN json object if we can found if data exist by jsonobj.has("element_name") by how can we check that data is jsonarray or json object, follow error gives error if only one events element found and throws JSONexception. JsonObject jObj; if (json.has("Events")) { try { JSONArray eventsArray = json.getJSONObject("Events"); ...

returning JSON and HTML from PHP script

Hi searched through the questions here, but couldn't find anything. I'm new at writing PHP and jQuery, so bear with me. What I'm trying to do is send an ajax request using jQuery to my script which runs a mysql query on data from my database and serializes it into the JSON format using php's json_encode. The response is then parsed with...

What's the correct way to get HTML from an AJAX Response in JSON Format?

Hi all, I have an AJAX request that creates a 'post', and upon successful post, I want to get HTML to inject back into the DOM. Right now I'm returning a JSON array that details success/error, and when I have a success I also include the HTML for the post in the response. So, I parse the response as JSON, and set a key in the JSON array...

JQuery filter items in JSon Array

Hi, I have a JSon array as below which I need to filter to get the correct child values from the test data below. var arrChildOptions2 = [{Parent:'opt1',Value:'opt1',Text:'Parent1 - Child 1'},{Parent:'opt2',Value:'opt1',Text:'Parent 2 - Child 1'},{Parent:'opt2',Value:'opt2',Text:'Parent 2 - Child 2'}]; The values are used to populate...

ASP.NET MVC Returning JSON Objects of ViewModels

Hi all, It seems recently that all I ever seem to post about is ASP.NET MVC with JSON - you would think I'd learn by now! However, strange things keep happening that I can't explain! I have a Controller method that returns a JsonResult: public JsonResult GetAllUserTasksForStage(int StageID, string Username) { var uM = ManagerProvi...

sorting complex JSON object

Refering to earlier questions about referencing elements of and sorting a JSON (javascript) array. See http://stackoverflow.com/questions/2074908/refer-to-an-element-of-json-javascript-object http://stackoverflow.com/questions/979256/how-to-sort-a-json-array Is it possible to sort one branch of a more complex javascript array, such as ...

What is the fastest JSON parser for JavaScript?

I want to show a list with 1000 rows using Json that's support by Struts2 like pug-in. I use flexigrid (jquery) to parse 1000 rows to display. But it's so slow, and sometimes my browser crashes. (Firefox & IE). So, what is the fastest Javascript framework to parse about 1000 rows? ...

WCF - How do I return clean JSON?

Hello, I am trying to return some JSON from a WCF service. This service simply returns some content from my database. I can get the data. However, I am concerned about the format of my JSON. Currently, the JSON that gets returned is formatted like this: {"d":"[{\"Age\":35,\"FirstName\":\"Peyton\",\"LastName\":\"Manning\"},{\"Age\":31,\...

In Rails, how do you render JSON using a view?

Suppose you're in your users controller and you want to get a json response for a show request, it'd be nice if you could create a file in your views/users/ dir, named show.json and after your users#show action is completed, it renders the file. Currently you need to do something along the lines of: def show @user = User.find( params...

Updating HTML via JSON/AJAX

I've been using JSON to handle AJAX functionality in my rails applications ever since I heard about it, because using RJS/rendering HTML "felt" wrong because it violated MVC. The first AJAX-heavy project I worked on ended up with 20-30 controller actions tied directly to specific UI-behaviors and my view code spread over controller acti...

Example of how to parse exiftool JSON output in Haskell

Completely stumped. Can't make sense of any of the documentation. Can someone please provide an example of how I can parse the following shortened exiftool output using the Haskell module Text.JSON? The data is generating using the command exiftool -G -j <files.jpg>. [{ "SourceFile": "DSC00690.JPG", "ExifTool:ExifToolVersion": 7.8...

php and JSON help!

I have a script for updating a database table. I need to return a JSON array and to update some tables with JQUERY. my php script: $update = mysql_query("UPDATE PLD_SEARCHES SET STATUS = 1, TOTAL_RESULTS = ".$scrapper->getTotalResults().",RESULTS = $resultCounter WHERE ID = ".$searchId); $output = array("status"=>"COMPLETED","results"...

PHP vs .NET JSON web service

My iPhone app communicates with a RESTful service that provides JSON output. I've been generating JSON using mainly PHP. If I use a .NET web service or WCF service, will there be any limitations or differences I should be aware of in regards to JSON as input/output for the service? I'm not sure what to expect from .NET in this regard....

access google map data from php

I want to build a json_encoded list of all restaurants nearby a point using PHP looking to build a php function which takes Parameters: Latitude,longitude,radius (in meters). And return a json_encoded list I have a API key and I work with js but I wat it done with server-side scripting php dose any one know how to do it. I want to...

Serializing objects containing django querysets.

Django provides tools to serialize querysets (django.core.serializers), but what about serializing querysets living inside other objects (like dictionaries)? I want to serialize the following dictionary: dictionary = { 'alfa': queryset1, 'beta': queryset2, } I decided to do this using simplejson (comes with django). I extended simpl...

Parsing JSON with JQuery

Hello, I have some JSON that looks like the following: [{"Age":35,"FirstName":"Peyton","LastName":"Manning"}, {"Age":31,"FirstName":"Drew","LastName":"Brees"}, {"Age":58,"FirstName":"Brett","LastName":"Favre"}] This JSON is passed into a function I have created called parseJSON. This function looks like this: function parseJS...

Django : json serialize a queryset which uses defer() or only()

Now I've been using json serializer and it works great. I had to modify my queries where I started using the only() & defer() filters, like so - retObj = OBJModel.objects.defer("create_dt").filter(loged_in_dt__gte=dtStart) After I've done the above, suddenly the json serializer is returning empty fields - {"pk": 19047, "model": "OBJ...