What you are doing is mostly correct. I see a couple of items that may be creating some issues, e.g. mis-assigned values.
For example, you are assigning accel.x to all three attributes values ax, ay, az. But it seems like you probably meant to assign ax = $.accel.x , ay =$.accel.y , az =$.accel.z
It seems you've mixed up "random" and "rand". The field name in your JSON is "random" so your attribute assignment should be rand = $.random
Where is "btn" in your JSON?