-1

I have a simple JSON array in Python Flask like this..

response = [{
    "success" : true,
    "sessionid" : "sdf3452",
    "border" : {
        "top"    : "452",
        "left"   : "454",
    }
}]

js = json.dumps(response)
resp = Response(js, status=200, mimetype='application/json')
return resp

When I try this I get an error complaining that the true value does not exist...

NameError: name 'true' is not defined

Any ideas why I can't return a boolean true?

fightstarr20
  • 11,682
  • 40
  • 154
  • 278
  • What you have is not a JSON array. It is Python source code. There is no `true` in Python. – zvone Jan 20 '19 at 15:42

1 Answers1

0

Answered my own question, python boolean values true and false are capitalized.

response = [{
    "success" : True,
    "sessionid" : "sdf3452",
    "border" : {
        "top"    : "452",
        "left"   : "454",
    }
}]

js = json.dumps(response)
resp = Response(js, status=200, mimetype='application/json')
return resp

This works fine now

fightstarr20
  • 11,682
  • 40
  • 154
  • 278