Dear ALL , 

i want to Generate json like this one :

{
 "Result":"OK",
 "Records":[
  {"PersonId":1,"Name":"Benjamin 
Button","Age":17,"RecordDate":"\/Date(1320259705710)\/"},
  {"PersonId":2,"Name":"Douglas 
Adams","Age":42,"RecordDate":"\/Date(1320259705710)\/"},
  {"PersonId":3,"Name":"Isaac 
Asimov","Age":26,"RecordDate":"\/Date(1320259705710)\/"},
  {"PersonId":4,"Name":"Thomas 
More","Age":65,"RecordDate":"\/Date(1320259705710)\/"}
 ]
}

so i did this :

def person():
    
    data = db().select(db.Person.ALL)
    
    mylist = {}
    
    mylist['Result'] = 'OK'
    for i in data:
     i.name = {'name':i.name,'age':i.age}
     mylist['Records'].append(i.name)
    return mylist


then i open person.json , but i keep getting the order like this : 


{"Records": [{"age": "222", "name": "hassan"}, {"age": "23", "name": "mazen"}], 
"Result": "OK"}


but i want the 'Result' : 'ok'  to be at the beginning , what can i do ?


best regards, 

-- 



Reply via email to