I am somewhat new to python and I am wondering what the best way is to generate json in a loop. I could just mash a bunch of strings together in the loop, but I'm sure there is a better way. Here's some more specifics. I am using app engine in python to create a service that returns json as a response.
So as an example, let's say someone requests a list of user records from the service. After the service queries for the records, it needs to return json for each record it found. Maybe something like this:
{records:
{record: { name:bob, email:[email protected], age:25 } },
{record: { name:steve, email:[email protected], age:30 } },
{record: { name:jimmy, email:[email protected], age:31 } },
}
Excuse my poorly formatted json. Thanks for your help.
json.dumps