On Mon, Nov 10, 2014 at 1:44 PM, Larry Martell <larry.mart...@gmail.com> wrote:
> I have a web page POST-ing a JSON object like this:
>
>                 var content = '{ "EnergylinxTariffMenu" : [' +
>                    '{ "FuelPage":"dual" , "DualMenu":"electric",' +
>                    '  "SupplierName":"npower", "MeterType": "",' +
>                    '  "TestLive":"test"} ]}';
>                 document.mainform.elements['json_content'].value =
> JSON.parse(content);

Why parse it?

>
> In my view I want to process this:
>
> import json
> jdata = json.loads(request.POST['json_content'])
>
> But that fails with:
>
> *** ValueError: Expecting value: line 1 column 2 (char 1)
>
> What is the proper way to decode this?

Depends what "this" is. I suspect that what is submitted is not JSON.
Add debug to determine what "json_content" Django is receiving.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1%2B9-2OffC9Cjqr-LY2x%3DKRiLC0N-iZ3_4Tz6YCEcVkBkg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to