angularjs - Expecting value: line 1 column 1 (char 0) python -


i'm newbie in python , trying parse data in application using these lines of codes

json_str = request.body.decode('utf-8')  py_str = json.loads(json_str) 

but i'm getting error on json.loads

expecting value: line 1 column 1 (char 0)

this json formatted data send angular app (updated)

object { clienttypeid: 6, clientname: "asdasd", clientid: 0, phoneno: "123", faxno: "123", ntn: "1238", gstnumber: "1982", officialaddress: "sads", mailingaddress: "asdasd", regstartdate: "17-aug-2016", 15 more… }

these values in json_str

clienttypeid=5&clientname=asdasd&clientid=0&phoneno=123&faxno=123&ntn=123&gstnumber=12&officialaddress=adkjh&mailingaddress=adjh&regstartdate=09-aug-2016&regenddate=16-aug-2016&status=1&cancreateuser=true&userquotafor=11&userquotatype=9&maxusers=132123&applyusercharges=true&applyreportcharges=true&emailinvoice=true&billingtype=1&usercharges=132&reportcharges=123&monthlycharges=123&billingdate=16-aug-2016&usersessionid=324

i don't know what's wrong in it.. can mention what's mistake is??

your data not json-formatted, not 1 included in updated answer. data javascript-object, not encoded string. please note "n" in json: notation -- format inspired how data written in javascript code, runtime javascript data not represented in json. "json" pasted how browser represents object you, not proper json (that {"clienttypeid": 6, ...} -- note quotes around property name).

when sending data server, have encode it. think sending json-encoded, aren't. sending "web form encoded" (data of type application/x-www-form-urlencoded).

now either have learn how send data in json format angular, or use correct parsing routine in python: urllib.parse.parse_qs. depending on library using, there might convenience method access data well, common use case.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -