2017-09-04 36 views
0

我有一個數據結構,如下面的外部文本文件所示。它更大,但格式保持不變。我如何使用這個文件來創建我可以使用的perl數據結構。我在想我可以做一個文件複製並替換所有:with =>。但接下來使用這個外部代碼是一個變量。從文件導入gns3數據結構到變量

彷彿是提前

該文件的格式

​​

感謝

{ 
    "auto_close" => "true", 
    "topology" => { 
     "drawings" => [], 
     "links" => [ 
      { 
       "link_id" => "2c1a64c9-a96e-4c94-ac3d-bbaeadde3773", 
       "nodes" => [ 
        { 
         "adapter_number" => 2, 
         "label" => { 
          "rotation" => 0, 
          "style" => "font-family =>", 
         }, 
         "node_id" => "0807cfc6-ffc9-4762-ad11-d021e2e49b0e", 
        }, 
        { 
         "adapter_number" => 0, 
         "label" => { 
          "rotation" => 0, 
          "style" => "fill-opacity => 1.0;", 
         }, 
         "node_id" => "aeab6b0b-6fd3-43d8-a547-7cd2752dc800", 
         "port_number" => 0 
        } 
       ] 
      } 
     ], 
     "nodes" => [ 
      { 
       "compute_id" => "local", 
       "label" => { 
        "rotation" => 0, 
        "style" => "font-family => TypeWriter;", 
        "text" => "East1", 
       }, 
       "name" => "East1", 
       "properties" => { 
        "auto_delete_disks" => "true", 
        "platform" => "c7200", 
        "power_supplies" => [ 
         1, 
         1 
        ], 
        "sensors" => [ 
         22 
        ], 
       }, 
       "symbol" => " =>/symbols/router.svg", 
       "z" => 1 
      }, 
     ] 
    }, 
    "type" => "topology", 
    "version" => "2.0.3" 
}; 
+0

會EVAL工作呢? – hoffmeister

回答