Hello kenneth,
That JSON is not well formed. Try adjusting with this:
js =
{"product_package":"basic_m","products":"31349","billing_name":"Kenneth","billing_surname":"Lundstr\u00f6m","e_mail":"[email protected]","billing_organization":"Testing","billing_job_description":"Tester","billing_address":"a:7:{s:12:\"thoroughfare\";s:18:\"Teststreet
5\";s:7:\"premise\";s:0:\"\";s:11:\"postal_code\";s:5:\"000012\";s:18:\"dependent_locality\";s:0:\"\";s:8:\"locality\";s:5:\"Test
city\";s:19:\"administrative_area\";s:0:\"\";s:7:\"country\";s:2:\"NO\";}","company_business_id":"123456789","billing_phone":"123456789","billing_mobile":"","delivery_checkbox":"","delivery_name":"","delivery_surname":"","delivery_organization":"","delivery_address":"N;","terms__conditions":"agree"}
billing_address = js['billing_address'].split(':', 2)[2]
billing_address = billing_address.replace('s:', '"s_')
billing_address = billing_address.replace(';', ',')
billing_address = billing_address.replace(',}', '}')
billing_address = billing_address.replace(':', '":')
billing_address_js = json.loads(billing_address)
2016-02-21 11:41 GMT-04:30 Kenneth <[email protected]>:
> Hi,
>
> the whole set is JSON, I can load it with json.loads och access the
> different fields. But the string inside billing_address is not I think JSON,
> but does anybody have any ideas what it could be and how to access it. I'd
> rather not start splitting it up and do a lot of trial and errors. But maybe
> that is the only way of doing it.
>
>
> Kenneth
>
>
>
> Den söndag 21 februari 2016 kl. 15:59:23 UTC+2 skrev Val K:
>>
>> Maybe I mistake, but JSON means arrays ([1,2, "any string", 5]) , hashes
>> ({"a":1, "b":"any string"}) and combinations ([{"a": [1,2,3], "b":2 }, 2,3
>> ]),
>> so , "a:7:{..." - isn't JSON
>>
>> On Sunday, February 21, 2016 at 2:46:47 PM UTC+3, Kenneth wrote:
>>>
>>> Hi,
>>>
>>> I don't access to change the webform, so I need to get by what I receive.
>>> It is a standard webform in Drupal that sends the JSON.
>>>
>>>
>>> Kenneth
>>>
>>>
>>> Den söndag 21 februari 2016 kl. 13:01:40 UTC+2 skrev Val K:
>>>>
>>>> How do you serialize form?
>>>> Jquery.param makes json in extended format by default, try use
>>>> traditional=true
>
> --
> 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 [email protected].
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.