simplejson

Proper way to deal with variations in JSON serialization

I have a web service that uses Python's SimpleJSON to serialize JSON, and a javascript/ client that uses Google's Visualization API. When I try to read in the JSON response using Google Data Table's Query method, I am getting a "invalid label" error. I noticed that Google spreadsheet outputs JSON without quotes around the object keys. ...

jQuery.getJSON doesn't trigger callback

Hi! I have a html code: <button>asd</button> <script type = "text/javascript"> $('button').click( function() { $.getJSON('/schedule/test/', function(json) { alert('json: ' + json + ' ...'); }); } ); </script> and corresponding view: def test(request): if request.method == 'GET': json = ...

Yahoo Pipes, simplejson and slashes

Im trying to use http://www.javarants.com/2008/04/13/using-google-app-engine-to-extend-yahoo-pipes/ as inspiration, but I'm having some troubles with the output. Its obvious when testing with the console and the App Engine "django util simplejson": /cygdrive/c/Program Files/Google/google_appengine/lib/django $ python Python 2.5.2 (r252...

Google Data Source JSON not valid?

I am implementing a Google Data Source using their Python Library. I would like the response from the library to be able to be imported in another Python script using the simplejson library. However, even their example doesn't validate in JSONLint: {cols: [{id:'name',label:'Name',type:'string'}, {id:'salary',label:'Salary',ty...

`json` and `simplejson` module differences in Python

I have seen many a projects use simplejson module than the in builtin Standard Library json. Also there seem to be many different simplejson modules What are the advantages of simplejson and which implementation is good? Why not, just use the standard builtin json module? ...

How to install SimpleJson Package for Python

http://pypi.python.org/pypi/simplejson I am just diving into the Python world and want to make a simple twitter application which requires the installation of simplejson but not sure how I can set it up and get it working.. I am on a Windows System ...

Python JSON encoding

I'm trying to encode data to JSON in Python and I been having a quite a bit of trouble. I believe the problem is simply a misunderstanding. I'm relatively new to Python and never really got familiar with the various Python data types, so that's most likely what's messing me up. Currently I am declaring a list, looping through and ano...

Decode complex JSON in Python

Hey, I have a JSON object created in PHP, that JSON object contains another escaped JSON string in one of it's cells: php > $insidejson = array('foo' => 'bar','foo1' => 'bar1'); php > $arr = array('a' => array('a1'=>json_encode($insidejson))); php > echo json_encode($arr); {"a":{"a1":"{\"foo\":\"bar\",\"foo1\":\"bar1\"}"}} Then, wit...

Python/Django n00b question about json encoding

Hello, I'm loading a json string in Django using simplejson obj = json.loads('{"name": "joe"}') person = obj.name this throws an error: 'dict' object has no attribute 'name' but when I pass 'obj' down to the view template and print it out via {{ obj.name }} it works! Why?? Many thanks, g ...

Get json data via url and use in python (simplejson)

I imagine this must have a simple answer, but I am struggling: I want to take a url (which outputs json) and get the data in a usable dictionary in python. I am stuck on the last step. >>> import urllib2 >>> import simplejson >>> req = urllib2.Request("http://vimeo.com/api/v2/video/38356.json", None, {'user-agent':'syncstream/vimeo'}) ...

Using Python simplejson to return pregenerated json

I have a GeoDjango model object that I want't to serialize to json. I do this in my view: lat = float(request.GET.get('lat')) lng = float(request.GET.get('lng')) a = Authority.objects.get(area__contains=Point(lng, lat)) if a: return HttpResponse(simplejson.dumps({'name': a.name, 'area': a.a...

Django : View returns JSON content_dictionary, how to decode in Javascript

Let me explain what I'm trying to do, and if someone could point the correct way to do it & a solution to where I'm stuck that would be great ! Someone types url www.ABC.com/showItem/Blackberry I lookup "Blackberry" in my database and find data for it, now I want to show its details one a page. Hence in the View I do this return_dat...

How to serialize db.Model objects to json?

When using from django.utils import simplejson on objects of types that derive from db.Model it throws exceptions. How to circumvent this? ...

Easiest way to serialize a simple class object with simplejson?

I'm trying to serialize a list of python objects with JSON (using simplejson) and am getting the error that the object "is not JSON serializable". The class is a simple class having fields that are only integers, strings, and floats, and inherits similar fields from one parent superclass, e.g.: class ParentClass: def __init__(self, ...

python json loads and unicode

I have the following case where I get the result of UTF-8 encoded HTTP response. I want to load the response content(JSON). However I don't know why I have to do 2 json.loads so that I get the final list: result = urllib2.urlopen(req).read() print result, type(result) #=> "[{\"pk\": 66, \"model\": \"core.job\", \"fields\": {\"customer\"...

installing simplejson on the google appengine

Super nub question time! I am trying to use simplejson on the google appengine. In a terminal on my machine I have simplejson installed and working. But my when I try to import it in a script running on the appengine I get an error saying no such library exists. If open the interactive console on my machine (from the link on http://local...

Simplejson dumps char \

Hi! Im programming with django and i need to serialize an object to a string, but i need to get the string \/ serialized. An example: simplejson.dumps({'id' : 'root\/leaf'}) I need an output like this: '{"id": "root\/leaf"}' but i get this: '{"id": "root\\\\leaf"}' Thank you!! PD: Sorry for my english :-P ...

Json unicode decoding in python's simplejson

I can't decode json strings like this: "\u0e4f\u0361\u032f\u0e4f" >>> import simplejson >>> simplejson.loads('"\u0e4f\u0361\u032f\u0e4f"', encoding='utf8') u'\u0e4f\u0361\u032f\u0e4f' However php json_decode works fine: json_decode('"\u0e4f\u0361\u032f\u0e4f"'); What am I doing wrong? ...

python simple json problem with a unicode string url "link": "http:\/\/www.mydomain.com" ??

i have a dictionary when i pass it over simplejson.dumps(dict) the json output has put some sort of encoding on a string url? "link": "http:\/\/www.mydomain.com" How can i stop this? Im using app engine simplejson. ...

python simpleJSONDecoder and complex JSON issue

In a unit test case that I am running, I get a KeyError exception on the 4th json object in the json text below because the piece of code responsible for decoding is looking for an object that isn't there, but should be. I went through the sub-objects and found that it was the "cpuid" object that causes the problem. When I remove it ...