Tagged Questions
0
votes
2answers
46 views
Convert Python String to Dictionary
I have a string:
A = "{user_id:34dd833,category:secondary,items:camera,type:sg_ser}"
I need to convert it to python dictionary, so that:
A = {"user_id":"34dd833", "category": "secondary", ...
0
votes
1answer
45 views
Strip leading 'u' from JSON for PHP
I have the following which I'm trying to parse in PHP
It's JSON but with leading 'u' (probably python indicators, but I'm not sure)
What's the quickest way to turn these into valid JSON? Or is this
...
2
votes
1answer
32 views
How to exclude specific fields on serialization with jsonpickle?
I'm using SQLAlchemy extension with Flask. While serializing my models (which are also used for database operations) using jsonpickle, I want some specific attributes to be ignored. Is there way that ...
2
votes
2answers
31 views
Django: convert QuerySet with related objects to JSON
Let's suppose I have two simple Models:
class Place(models.Model):
name = models.CharField(max_length=200)
address = models.CharField(max_length=200)
class Event(models.Model):
name = ...
-5
votes
2answers
52 views
2
votes
2answers
57 views
Python dict call function as value
I'm creating a dict in python using returned json.
one of the values I want to be a shortuuid, so I put a function as the value.
I want that function called and the value replaced with what that ...
0
votes
2answers
58 views
add a variable conditionally in python code
I am new to python and was wondering in the below python code how to add a variable conditionally.
requestBody = json.dumps({"accountId":accountId,
"emailSubject":customData.emailSubject,
...
-2
votes
1answer
33 views
Conversion required for part of an html code that is in JSON format
I have an html code in which there is a json string generated by another program and the whole json string is commented in the html code. But there is some vital information which has to be parsed out ...
1
vote
1answer
29 views
Is there a way to get the Pyramid json renderer to output formatted, pretty printed, output?
I like my json output to be nicely formatted, even for a REST API. It helps when debugging, etc. The extra overhead is minimal, especially when using gzip
Is there anyway to tell the pyramid json ...
2
votes
4answers
56 views
Return a list of all variable names in a python nested dict/json document in dot notation
I'm looking for a function that operates on a python arbitrarily nested dict/array in JSON-esque format and returns a list of strings keying all the variable names it contains, to infinite depth. So, ...
4
votes
3answers
172 views
Remove whitespaces and newlines from JSON file
I have a JSON file that has the following structure:
{
"name":[
{
"someKey": "\n\n some Value "
},
{
"someKey": "another value "
}
...
15
votes
2answers
593 views
Flask slow at retrieving post data from request?
I'm writing flask application that accepts POST requests with json data. I noticed huge differences in response time based on data size being passed to application. After debugging I narrowed down ...
8
votes
7answers
2k views
How to beautify JSON in Python or through command line
Can someone suggest how I can beautify JSON in Python or through the command line (I use OS X)?
The only online based JSON beautifier which could do it was: http://jsonviewer.stack.hu/.
I need to ...
1
vote
2answers
871 views
Why is this except being called? - Python
I have a method that checks a JSON payload for JSON decoding errors, and KeyErrors. For some reason, the except statement with the KeyError is getting called, but then shows there was in fact, no ...
43
votes
11answers
22k views
How to get string Objects instead Unicode ones from JSON in Python?
I'm using Python (Python 2.5.2 on Ubuntu 8.10) to parse JSON from (ASCII encoded) text files. When loading these files with json (simplejson), all my string values are cast to Unicode objects instead ...