Drupal fetching object I am trying to fetch an object:

$field_name= 'field_test';
$json_code = $node-&gt;$field_name['und'][0]['value'];


NOT WORKING

$json_code = $node-&gt;field_test['und'][0]['value'];


WORKING

I must have variable because it's every time different field name

any solution?
Your PHP is incorrect for what you're trying to accomplish.

Drupal has field_get_items() for this purpose, though:

$items = field_get_items('node', $node, $field_name);
...