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
18
votes
3 answers

Converting a string to JSON in C#

I'm trying to use Simple JSON to convert this string to JSON…
Trip
  • 26,756
  • 46
  • 158
  • 277
14
votes
1 answer

What is faster - Loading a pickled dictionary object or Loading a JSON file - to a dictionary?

What is faster: (A) 'Unpickling' (Loading) a pickled dictionary object, using pickle.load() or (B) Loading a JSON file to a dictionary using simplejson.load() Assuming: The pickled object file exists already in case A, and that the JSON file exists…
Pranjal Mittal
  • 10,772
  • 18
  • 74
  • 99
13
votes
3 answers

Single versus double quotes in json loads in Python

I notice that single quotes cause simplejson's loads function to fail: >>> import simplejson as json >>> json.loads("\"foo\"") 'foo' >>> json.loads("\'foo\'") Traceback (most recent call last): ... ValueError: No JSON object could be decoded I'm…
user248237
12
votes
8 answers

How to ensure that a python dict keys are lowercase?

I have a dict that I want to convert in JSON using simplejson. How can I ensure that all the keys of my dict are lowercase ? { "DISTANCE": 17.059918745802999, "name": "Foo Bar", "Restaurant": { "name": "Foo…
Natim
  • 17,274
  • 23
  • 92
  • 150
12
votes
3 answers

How to solve the ImportError: cannot import name simplejson in Django

I'm trying to build a realtime chat app in Django(1.7.1). It seems that I needed to install Redis and ishout.js. So I installed them by following the instructions. After making the project in Django, I put 'drealtime' under the INSTALLED_APPS, and…
Sungpah Lee
  • 1,003
  • 1
  • 13
  • 31
11
votes
4 answers

How to search/find In JSON with java

I have a below JSON string from the below i want to find/search criteria in JSON String. To find the Number of keys present. To get the values of given key(if we have array) { "store": { "book": [ { …
Ssire
  • 123
  • 1
  • 1
  • 6
10
votes
3 answers

simplejson.loads() get Invalid \escape: 'x'

I am learning how to use simplejson to decode JSON file. But I suffered the "invalid \escape" error. Here is the code import simplejson as json def main(): json.loads(r'{"test":"\x27"}') if __name__ == '__main__': main() And here is the…
kkpattern
  • 948
  • 2
  • 7
  • 31
10
votes
2 answers

parsing json fields in python

Is there a good tutorial on parsing json attributes in python? I would like to be able to parse the true value for "ok" field. As well as the index named "client_ind_1". I don't understand the python document coverage on this topic. If someone could…
Horse Voice
  • 8,138
  • 15
  • 69
  • 120
9
votes
2 answers

Python 2.7 on App Engine, simplejson vs native json, who's faster?

I've had the understanding that simplejson is much faster than the native json in Python, such as this thread: What are the differences between json and simplejson Python modules? However, I was just thrown for a loop when I read in App Engines…
adam
  • 3,498
  • 6
  • 34
  • 46
9
votes
4 answers

java.lang.String cannot be cast to org.json.simple.JSONObject simple-json

I am getting strange problem while trying to parse a simple json using simple-json by google. Here is my code which is not working: String s = args[0].toString(); JSONObject json = (JSONObject)new JSONParser().parse(s); When I execute, it will give…
Roshan Wijesena
  • 3,106
  • 8
  • 38
  • 57
8
votes
2 answers

Decode json and Iterate through items in django template

Hi I am using simplejson to import some json and then decode for use within a django template, this is the decoded json: {u'ServerID': 1, u'Cache': {u'CacheBusted': False, u'FromCache': True}, u'Result': [{u'Url':…
jon21021985
  • 105
  • 2
  • 2
  • 4
8
votes
1 answer

Deserializing a huge json string to python objects

I am using simplejson to deserialize json string to python objects. I have a custom written object_hook that takes care of deserializing the json back to my domain objects. The problem is, when my json string is huge (i.e. the server is returning…
pragnya
  • 81
  • 4
7
votes
2 answers

How to make simplejson serializable class

I have a class defined like this class A: def __init__(self): self.item1 = None def __repr__(self): return str(self.__dict__) when I do: >>> import simplejson >>> myA = A() >>> simplejson.dumps(myA) TypeError: {'item1':…
dnuske
  • 558
  • 7
  • 21
7
votes
1 answer

How do I fix a "JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)"?

I'm trying to get Twitter API search results for a given hashtag using Python, but I'm having trouble with this "No JSON object could be decoded" error. I had to add the extra % towards the end of the URL to prevent a string formatting error. Could…
user374372
  • 190
  • 2
  • 4
  • 14
6
votes
3 answers

Is there any way to make simplejson less strict?

I'm interested in having simplejson.loads() successfully parse the following: {foo:3} It throws a JSONDecodeError saying "expecting property name" but in reality it's saying "I require double quotes around my property names". This is annoying for…
slacy
  • 11,397
  • 8
  • 56
  • 61
1
2
3
19 20