Questions tagged [simplejson]

Simple, fast, extensible JSON encoder/decoder for Python.

simplejson exposes an API familiar to users of the standard library marshal and pickle modules.

simplejson was previously hosted at http://code.google.com/p/simplejson/, with more current information available at http://pypi.python.org/pypi/simplejson/ and http://simplejson.github.com/simplejson/.

Disambiguation

JSON.simple is a Java library with a similar name. On StackOverflow, JSON.simple questions are tagged with .

298 questions
414
votes
13 answers

What are the differences between json and simplejson Python modules?

I have seen many projects using simplejson module instead of json module from the Standard Library. Also, there are many different simplejson modules. Why would use these alternatives, instead of the one in the Standard Library?
lprsd
  • 84,407
  • 47
  • 135
  • 168
108
votes
5 answers

Getting values from JSON using Python

While I am trying to retrieve values from JSON string, it gives me an error: data = json.loads('{"lat":444, "lon":555}') return data["lat"] But, if I iterate over the data, it gives me the elements (lat and lon), but not the values: data =…
BrunoVillanova
  • 1,221
  • 2
  • 8
  • 14
62
votes
7 answers

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…
KeyboardInterrupt
  • 3,483
  • 8
  • 36
  • 41
54
votes
4 answers

Why does json serialization of datetime objects in python not work out of the box for datetime objects

Why does the json serialization not work for datetime objects . As I understand json serialization the basic idea for any object can be call the __str__ builtin function and then urlencode the object that you get as a response. But in case of…
dusual
  • 2,097
  • 3
  • 19
  • 26
45
votes
2 answers

Reading JSON from SimpleHTTPServer Post data

I am trying to build a simple REST server with python SimpleHTTPServer. I am having problem reading data from the post message. Please let me know if I am doing it right. from SimpleHTTPServer import SimpleHTTPRequestHandler import…
Gatothgaj
  • 1,633
  • 2
  • 16
  • 27
43
votes
9 answers

SimpleJSON and NumPy array

What is the most efficient way of serializing a numpy array using simplejson?
epoch
  • 1,337
  • 2
  • 15
  • 23
41
votes
10 answers

Python JSON module has no attribute 'dumps'

I am running Python 2.7 (x64 Linux) and trying to convert a dict to a JSON object. >>> import sys >>> sys.version_info sys.version_info(major=2, minor=7, micro=0, releaselevel='final', serial=0) I am trying to use simplejson (falling back to json…
Alex Reynolds
  • 95,983
  • 54
  • 240
  • 345
38
votes
5 answers

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
TimLeung
  • 3,459
  • 6
  • 42
  • 59
37
votes
3 answers

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 =…
thornomad
  • 6,707
  • 10
  • 53
  • 78
32
votes
7 answers

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…
user248237
31
votes
9 answers

Exclude empty/null values from JSON serialization

I am serializing multiple nested dictionaries to JSON using Python with simplejson. Is there any way to automatically exclude empty/null values? For example, serialize this: { "dict1" : { "key1" : "value1", "key2" : None } …
simao
  • 14,491
  • 9
  • 55
  • 66
25
votes
4 answers

jQuery.getJSON doesn't trigger callback

I have a html code: and…
chriss
  • 4,349
  • 8
  • 29
  • 36
21
votes
8 answers

Json dumping a dict throws TypeError: keys must be a string

I am attempting to convert the following dict into JSON using json.dumps: { 'post_engaged': 36, 'post_impressions': 491, 'post_story': 23, 'comment_count': 6, 'created_time': '03:02 AM, Sep 30, 2012', 'message':…
Viren Rajput
  • 5,426
  • 5
  • 30
  • 41
20
votes
2 answers

Check whether the JSON (object property exists) & print it as unicode decoded

I get the following data from the Instagram API, I m trying to get the text property from the caption using the following code: data = simplejson.load(info) # info is retrieved using the urllib2 for post in data['data']: if…
Viren Rajput
  • 5,426
  • 5
  • 30
  • 41
19
votes
5 answers

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?
Jader Dias
  • 88,211
  • 155
  • 421
  • 625
1
2 3
19 20