In my Rails application, I am sending a complex JSON string that needs to be decrypted. This is not a problem that I know how.
Now, before I implement everything that I try to get in some examples of the JSON structure, to see if I can get all the variables. The problem is that names can be variables.
{"configurations" : [
{ "drinks" : [
{"menus" : [
{ "hot" : [
{"id":15,"unit":"0.33", "price":"1", "currency":"Euro", "position": 4},
{"id":15,"unit":"0.33", "price":"1", "currency":"Euro", "position": 6}
] },
{ "cold" : [
{"id":15,"unit":"0.33", "price":"1", "currency":"Euro", "position": 4},
{"id":15,"unit":"0.33", "price":"1", "currency":"Euro", "position": 6}
] },
{ "terminals" : [ {"id" : 4}, {"id": 6}, {"id": 7} ] },
{ "keys" : { "debit" : "on", "credit": "off" } }
] }
] } ] }
So, now the following fields are variables : “drinks”, “hot”, “cold” . All other fields will be called the same.
Now, I would like to access every variable in this JSON string after I decrypted it. Before implementing it, I tried simple JSON:
{"configuration" : [ { "drinks" : [ { "id":15, "unit":"0.33" } ] } ] }
After decoding in rails, resulting in
{ "configuration" => [{"drinks" => [{"id" => 15, "unit" => "0.33" }]}]}
, , , id unit, "". .
: JSON (id), , JSON. (, , 4 ^^).