Marcus Mumford
Marcus Mumford

Reputation: 11

Add value into JSON with PERL

I create my json with PERL:

$perl_data{form . $num}{filed1} = {name_field => $name, type => $type, length => $max};

The result is this:

{
   "form1" : {
      "codifica" : "multipart/form-data",
      "filed0" : {
         "name_field" : "nome",
         "type" : "TEXT",
         "length" : ""
      },
      "action" : "nulla.php",
      "filed1" : {
         "name_field" : "cognome",
         "valore" : "mamma",
         "type" : "TEXT",
         "length" : "100"
      },
      "metodo" : "GET"
   }
}

If I want to add further data to JSON at $perl_data{form . $num}{filed1} at a later date, how can I do that?

For example:

$perl_data{form . $num}{filed1} = {name_field => $name, type => $type, length => $max};
..code..
..code..
..code..
??? how i can add "key => $value" into $perl_data{form . $num}{filed1}?

Thank's!

Upvotes: 0

Views: 66

Answers (1)

Kjetil S.
Kjetil S.

Reputation: 3777

$perl_data{"form$num"}{filed1}{key} = $value;

Upvotes: 4

Related Questions