When I added variables to JSON as shown in the example you provided, the numbers all turned into 0.
Additionally, username (String type) is not written in the JSON either.
Where do you see this? Check in the debugger, I bet the values in JSON are all correct.
Maybe your PHP script expects text values instead of numbers? In this case you need to use str(variable) to convert numbers to text.
JSON set "keyname" to str(variable)
Also in your first comment the parent key in JSON was "score", but now you say it's "score_table"