0

I've got a HTML5 game that encodes character data into JSON then uses POST to send it to a php file. This is what the formdata looks like

{"onScreen":3,"quoteNum":4,"CHARACTER1":{"screenPos":1,"charNum":0,"bodyNum":0,"hairNum":0,"eyeNum":0,"hairColNum":0,"name":""},"CHARACTER2":{"screenPos":2,"charNum":0,"bodyNum":0,"hairNum":0,"eyeNum":0,"hairColNum":0,"name":""},"CHARACTER3":{"screenPos":3,"charNum":0,"bodyNum":0,"hairNum":0,"eyeNum":0,"hairColNum":0,"name":""}}:

The only problem is I don't know how to retrieve the encoded JSON in php. When I simply try to print the data php just prints "array".

How do I simply get php to print the JSON data it was posted?

Spike
  • 57
  • 1
  • 2
  • 8
  • This might help: http://stackoverflow.com/questions/6054033/pretty-printing-json-with-php – Katie Oct 10 '16 at 16:14

1 Answers1

1

Try to get the encoded json on server side like this after decoding it to array.

print '<pre>';
print_r(json_decode($_POST,1)) 
print '</pre>'

For your info: your json string contains a colon at the end :P

A l w a y s S u n n y
  • 36,497
  • 8
  • 60
  • 103