json

parsing json format in javascript

{"0":{"name":{"name_id":"How to battle","tab_level":"2"},"job_reward":{"job_money":"10000","job_exp":"50","job_energy":"23"}},"job_required_items":[{"filename":"sword.gif","no":"2"}],"1":{"name":{"name_id":"Check for battle","tab_level":"2"},"job_reward":{"job_money":"1000","job_exp":"12","job_energy":"10"}}} i want to parse this json ...

Recursion for json_encode only on failed MySQL query

Scenario: Two different objects that get their data from a MySQL database (originally, then subsequently from a serialized/unserialized SESSION key) are causing a recursion error for json_encode, but ONLY when another, later INSERT query has failed. The INSERT query will fail when certain elements are NULL (as mandated by the table str...

getting incomplete array in php

<?php $tab=1;/*$_GET['tab'];*/ $id=1111;/*$_GET['id'];*/ include_once('solve.php'); $query="SELECT user_job.level1, user_job.tab_level, job.money_gain, job.exp_gain, job.energy_required, job.name,job.job_id FROM user_job RIGHT JOIN job USING(job_id) WHERE job.tab=".$tab." AND user_job.user_id=".$id." LIMIT 0,10"; $resu...

deserialize json

I get this JSON resposne from a server: {"User1":0, "User2":0,"User3":0,"User4":0,"User5":0,"UserN":0,} Users can be from 0 to N. I want to deserialize this JSON string into a List of Users public class User { public string Name{get;set;} public string Status{get;set;} } I try this but it doesn't work. List<Users> peoples; peo...

Returning JSON from ASMX, and handling it correctly in Javascript

I realize there are tonnes of similar questions already up here but I cannot figure this one out. I have a Web Service (C#, .net 3.5). The essential Code you need to know of is as follows: [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.Web.Script.Services.ScriptS...

jQuery AJAX call messes up character encoding

I have a servlet that outputs JSON. The output encoding for the servlet is ISO-8859-1. Pages in our webapp are also set to ISO-8859-1. I would use UTF-8, but this is outside my control; we have to use ISO-8859-1. When I hit the servlet by itself, I can see JSON data that has been outputted. The character encoding is correct, and none of...

Sorting issues in flexigrid with "json" data

I'm currently using flexigrid to display data in a current project, but am running into issues with its ability to properly sort certain columns that contain dates or numbers. The data is being sent from a ColdFusion CFC that selects the appropriate data and then delivers it in the proper "json" format. As the date/time stamps and other ...

Is it possible to preload an entire MyISAM dataset using PHP & jSon?

For Example Let say we have 1000 products in a single category. And we would like to Filter through these products. As we Filter through the products using json. Each time we have need run a separate query to the DB. We were wondering if any one knows if it's possible display a preload the products table. For example preload bar: ini...

display json text as a friendly list in django admin

I have a JSONField (http://djangosnippets.org/snippets/1478/) in a model and I'm trying to find out the best way to display the data to the admin user rather than json. Does anyone know the best way to do this in django admin? For instance, I would like {u'field_user_name': u'foo bar', u'field_email': u'[email protected]'} to display as...

How do I call and decode a JSON web service from PHP?

From within PHP, how can I call an external JSON web service and then decode the returned string? For example (pseudo-code): <?php $var jsonStr = json_decode("http://maps.google.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&amp;sensor=false"); ?> ...

PHP: How do I get an attribute from a JSON array?

I have the following JSON array: <?php $json = { "status": "OK", "results": [ { "types": [ "street_address" ], "formatted_address": "5721 N Northcott Ave, Chicago, IL 60631, USA", "address_components": [ { "long_name": "5721", "short_name": "5721", "types": [ "street_number" ] }, { "long_n...

Send json object to mysql using jquery/javascript/php?

I have a page that generates json data from several fields and I want to send it to a mysql database. I currently have a link, the user clicks the link, the javascript takes the information they've inputed and sends it to a server. Due to the nature, I need all the data in one field in the mysql database. Any ideas? EDIT: The data comes...

How do i convert a json object to a string?

How do i convert a json object to a json string? var o = { name: "a", id:5}; var sz = //??? alert('The json will look like ' + sz); -edit- i forgot i would like to do it in jQuery or naively if possible ...

Best way to handle .NET json [1,2,"three"]

-edit- Maybe there is a solution by using attributes? I found the weirdest json. It looks like the string below. The only way i can think of to handle it is to use an object array. I never seen ints and strings mixed in an array below. I am then forced to typecast. Is there a better way to get the ints and string? NOTE: The first arra...

Rails: Hash#to_json - split over multiple lines?

I'm having a slight annoyance with the javascript_I18n plugin, which generates js-friendly versions of the I18n translation tables, so that you can localise your javascript. It all works fine, but it works by calling to_json on each locale's translations hash and outputting the results into a file. When you call to_json on a hash the r...

Display AJAX controller action result using HtmlHelpers

Hi, I have a fairly complex object which has some C# code written to render it as HTML in various views. There is also a view which can call an AJAX method of a controller, which returns the complex object serialized to JSON which should then be displayed. This seems to leave me requriring complicated duplicate code to render the resu...

Groovy/Grails JSON converting of complex objects and collections.

I have following mapping representing categories tree: class Category { String name static belongsTo = [parent: Category] static hasMany = [categories: Category] } The thing I want to do is to render all of the category tree and exclude field parent from rendering. render category as JSON renders only first level of hiera...

iPhone Parsing JSON : delegate methods

Hi everyone. I'm using this JSON framework. It's working well but I would like to put a loading view on my main screen to show that the iphone is downloading datas. I have searched for some delegate methode like - jsonBeginParse and - jsonEndParse but unsuccessfully. Have got an idea ? Thanks a lot ! ...

How can I access a specific json object using jquery and json?

I'm having a problem trying to return a specific record using jQuery and JSON. I'm passing a variable to the function and want to output only the data matching the id I've set when the function is executed. Right now, my function looks like this: function getEffectsData(myNum){ $.getJSON("jsonscript.php", { id: +myNum },function(da...

jQuery .getJSON not working...

Hi guys, I'm just learning how to utilise ajax/json with jquery and I've hit a brick wall that I just don't understand. Here is my code - VERY simple code: $("#click").click(function() { $.getJSON("http://localhost/jsontest/a.json", function(data) { alert("done"); }); }); Basically, load a.json and send an alert...