yes i remove the unquote and saved request.vars directly. Also went to admin and by hand created a new record with
{"Gestão":1} on the json field and it was saved as {u'Gs\xe3\x00cn': 1} so far so good , i understand now that saving in json fields encodes the data. Now i need to read that data and decode it. Regards António 2016-08-19 16:03 GMT+01:00 Marlysson Silva <marlyss...@gmail.com>: > You removed the urllib.uquote() ? And after just receiving the request > directly.. > > Em sexta-feira, 19 de agosto de 2016 11:51:54 UTC-3, Ramos escreveu: >> >> Ok got it. >> If i create a new record via admin with >> >> {"Gestão":1} in the json Field, after saving the new record i get it as >> >> {u'Gs\xe3\x00cn': 1} >> >> You said its utf-8 encoded >> How do i decode it again to "Gestão" ? >> u'Gs\xe3\x00cn'.decode('utf-8') does not work.. >> >> sorry and thank you for your time. >> >> António >> >> >> 2016-08-19 15:16 GMT+01:00 Niphlod <nip...@gmail.com>: >> >>> why don't you just pass request.vars without quoting and unquoting ???? >>> anyway, json is always utf-8 encoded. that's the difference you're >>> seeing. >>> >>> >>> On Friday, August 19, 2016 at 11:43:55 AM UTC+2, Ramos wrote: >>>> >>>> Hi,im starting a new post because i found that JSON fields change data >>>> as they are saved. >>>> So repeating again the problem posted before >>>> >>>> >>>> My model >>>> db.define_table('responses', >>>> Field('f1'), >>>> Field('allresponses','json')) >>>> >>>> My controller >>>> def getit(): >>>> ret={} >>>> for x in request.vars: >>>> db.responses.insert(f1=urllib.unquote(x)) >>>> ret[urllib.unquote(x)]=request.vars[x]; >>>> db.responses.insert(allresponses=ret) >>>> >>>> i get in my request.vars >>>> >>>> {'Timestamp': '8/19/2016 9:54:44', >>>> 'Sistema%20de%20Gest%C3%A3o%20de%20Qualidade': >>>> 'sss'} >>>> >>>> after executing the controller code,when i look at table responses i >>>> see in allresponses field >>>> {'Timestamp': 8/19/2016 9:54:44', u'Sistema de Gest\xe3o\x00 >>>> \x00d\x00e\x00 \x00Q\x00u\x00': 'sss'} >>>> >>>> but field f1 is correct >>>> "Sistema de Gestão de Qualidade" >>>> >>>> So how can i deal with this? >>>> This is just a test but i will get many keys in request vars and so a >>>> json field would be better but need to solve this issue. >>>> >>>> Regards >>>> António >>>> >>>> -- >>> Resources: >>> - http://web2py.com >>> - http://web2py.com/book (Documentation) >>> - http://github.com/web2py/web2py (Source code) >>> - https://code.google.com/p/web2py/issues/list (Report Issues) >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "web2py-users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to web2py+un...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.