2013-08-28 31 views
0

當使用谷歌路線api並將選項設置爲true時,某些建議的路線會超過公園。其他人是否已經觀察到這種行爲?以下是我打的網址,谷歌路線api - 一些備選路線經過公園

http://maps.googleapis.com/maps/api/directions/json?origin=37.557139,-121.975332&destination=37.539156,-121.923666&&alternatives=true&sensor=false

它返回下列3條備選路線JSON響應,

{ 
    "routes" : [ 
     { 
     "bounds" : { 
      "northeast" : { 
       "lat" : 37.56534449999999, 
       "lng" : -121.923525 
      }, 
      "southwest" : { 
       "lat" : 37.5392255, 
       "lng" : -121.9749241 
      } 
     }, 
     "copyrights" : "Map data ©2013 Google", 
     "legs" : [ 
      { 
       "distance" : { 
        "text" : "3.7 mi", 
        "value" : 6020 
       }, 
       "duration" : { 
        "text" : "9 mins", 
        "value" : 531 
       }, 
       "end_address" : "42701-42753 Mission Boulevard, Fremont, CA 94539, USA", 
       "end_location" : { 
        "lat" : 37.5392255, 
        "lng" : -121.923525 
       }, 
       "start_address" : "Fremont BART Station, Fremont, CA 94536, USA", 
       "start_location" : { 
        "lat" : 37.5576351, 
        "lng" : -121.9749241 
       }, 
       "steps" : [ 
        { 
        "distance" : { 
         "text" : "400 ft", 
         "value" : 122 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 50 
        }, 
        "end_location" : { 
         "lat" : 37.5570393, 
         "lng" : -121.9737687 
        }, 
        "html_instructions" : "Head \u003cb\u003esoutheast\u003c/b\u003e toward \u003cb\u003eWalnut Ave\u003c/b\u003e", 
        "polyline" : { 
         "points" : "[email protected]`A{BJY" 
        }, 
        "start_location" : { 
         "lat" : 37.5576351, 
         "lng" : -121.9749241 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.9 mi", 
         "value" : 1406 
        }, 
        "duration" : { 
         "text" : "2 mins", 
         "value" : 90 
        }, 
        "end_location" : { 
         "lat" : 37.5653107, 
         "lng" : -121.9618013 
        }, 
        "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eWalnut Ave\u003c/b\u003e", 
        "maneuver" : "turn-left", 
        "polyline" : { 
         "points" : "ojfdF`_ngVUQQMqAaA]][email protected]@US][email protected]}@[email protected]{B}BkEqAgCsDsH][email protected]_A{[email protected]@{@" 
        }, 
        "start_location" : { 
         "lat" : 37.5570393, 
         "lng" : -121.9737687 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "2.8 mi", 
         "value" : 4492 
        }, 
        "duration" : { 
         "text" : "7 mins", 
         "value" : 391 
        }, 
        "end_location" : { 
         "lat" : 37.5392255, 
         "lng" : -121.923525 
        }, 
        "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eMission Blvd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eDestination will be on the right\u003c/div\u003e", 
        "maneuver" : "turn-right", 
        "polyline" : { 
         "points" : "e~gdFftkgVE]?G?G?EBIBM~JwIlAgA`[email protected]@zA}AZ[dDmGxHuNxAoCP][email protected][email protected]@aBzAsCzIsO|AsCdGqKbBuCN][email protected]@}[email protected]}[email protected]@[email protected]@[email protected]`@{@zAaD\\[email protected]@[email protected]_LpG{M`[email protected]@[email protected][[email protected]@@[email protected]{@[email protected]@" 
        }, 
        "start_location" : { 
         "lat" : 37.5653107, 
         "lng" : -121.9618013 
        }, 
        "travel_mode" : "DRIVING" 
        } 
       ], 
       "via_waypoint" : [] 
      } 
     ], 
     "overview_polyline" : { 
      "points" : "[email protected]@{@{@][email protected][email protected]?MFWlM_L`EeDnBiB~B_CZ[[email protected]|CsG|[email protected]@[email protected]@`@[email protected]|[email protected]" 
     }, 
     "summary" : "Mission Blvd", 
     "warnings" : [], 
     "waypoint_order" : [] 
     }, 
     { 
     "bounds" : { 
      "northeast" : { 
       "lat" : 37.5576351, 
       "lng" : -121.923525 
      }, 
      "southwest" : { 
       "lat" : 37.5311789, 
       "lng" : -121.977954 
      } 
     }, 
     "copyrights" : "Map data ©2013 Google", 
     "legs" : [ 
      { 
       "distance" : { 
        "text" : "4.9 mi", 
        "value" : 7824 
       }, 
       "duration" : { 
        "text" : "11 mins", 
        "value" : 653 
       }, 
       "end_address" : "42701-42753 Mission Boulevard, Fremont, CA 94539, USA", 
       "end_location" : { 
        "lat" : 37.5392255, 
        "lng" : -121.923525 
       }, 
       "start_address" : "Fremont BART Station, Fremont, CA 94536, USA", 
       "start_location" : { 
        "lat" : 37.5576351, 
        "lng" : -121.9749241 
       }, 
       "steps" : [ 
        { 
        "distance" : { 
         "text" : "354 ft", 
         "value" : 108 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 16 
        }, 
        "end_location" : { 
         "lat" : 37.5571031, 
         "lng" : -121.9739004 
        }, 
        "html_instructions" : "Head \u003cb\u003esoutheast\u003c/b\u003e toward \u003cb\u003eWalnut Ave\u003c/b\u003e", 
        "polyline" : { 
         "points" : "[email protected]`A{B" 
        }, 
        "start_location" : { 
         "lat" : 37.5576351, 
         "lng" : -121.9749241 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.4 mi", 
         "value" : 683 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 74 
        }, 
        "end_location" : { 
         "lat" : 37.5518666, 
         "lng" : -121.977954 
        }, 
        "html_instructions" : "Take the 1st \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eWalnut Ave\u003c/b\u003e", 
        "polyline" : { 
         "points" : "{jfdFz_ngVXRzB|A`@[email protected]`@XDBRNHHVR`[email protected]@[email protected]@VRzAdAVR" 
        }, 
        "start_location" : { 
         "lat" : 37.5571031, 
         "lng" : -121.9739004 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.3 mi", 
         "value" : 507 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 66 
        }, 
        "end_location" : { 
         "lat" : 37.5493906, 
         "lng" : -121.9731305 
        }, 
        "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003ePaseo Padre Pkwy\u003c/b\u003e", 
        "maneuver" : "turn-left", 
        "polyline" : { 
         "points" : "[email protected]@[email protected]|AqD|AwDpA}CfBoE" 
        }, 
        "start_location" : { 
         "lat" : 37.5518666, 
         "lng" : -121.977954 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "2.7 mi", 
         "value" : 4408 
        }, 
        "duration" : { 
         "text" : "6 mins", 
         "value" : 330 
        }, 
        "end_location" : { 
         "lat" : 37.5316415, 
         "lng" : -121.9341935 
        }, 
        "html_instructions" : "Continue straight to stay on \u003cb\u003ePaseo Padre Pkwy\u003c/b\u003e", 
        "maneuver" : "straight", 
        "polyline" : { 
         "points" : "uzddF`{[email protected]@[email protected][email protected]@[email protected]@}@[email protected]@[email protected][email protected]_A^[email protected]@aAP[T][email protected]@V{@[email protected]@[email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]}@aA{[email protected]@[email protected]?EL{@[email protected]@[email protected]@iA^[email protected]\\[email protected]@[email protected]@_B\\[email protected]@{@[email protected]@[email protected]{AT}[email protected][email protected]@[email protected]@[email protected]@PWPO`@[TMVKZI\\[email protected][email protected]|@[email protected]@[email protected][email protected]}@[email protected]@[email protected]@CFMJ[\\_A`@[email protected]@\\gAJQ^[email protected]@[email protected]@" 
        }, 
        "start_location" : { 
         "lat" : 37.5493906, 
         "lng" : -121.9731305 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.2 mi", 
         "value" : 396 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 46 
        }, 
        "end_location" : { 
         "lat" : 37.5311789, 
         "lng" : -121.9386345 
        }, 
        "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eWashington Blvd\u003c/b\u003e", 
        "maneuver" : "turn-right", 
        "polyline" : { 
         "points" : "[email protected]`BB`@NtDLvBLnC" 
        }, 
        "start_location" : { 
         "lat" : 37.5316415, 
         "lng" : -121.9341935 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.8 mi", 
         "value" : 1365 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 82 
        }, 
        "end_location" : { 
         "lat" : 37.5385712, 
         "lng" : -121.927027 
        }, 
        "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e to merge onto \u003cb\u003eI-680 N\u003c/b\u003e toward \u003cb\u003eSacramento\u003c/b\u003e", 
        "polyline" : { 
         "points" : "{[email protected][[email protected]@[email protected]@[email protected][email protected]@[email protected]@][email protected]@[email protected][[email protected]}CoCgG" 
        }, 
        "start_location" : { 
         "lat" : 37.5311789, 
         "lng" : -121.9386345 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.2 mi", 
         "value" : 312 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 21 
        }, 
        "end_location" : { 
         "lat" : 37.5395679, 
         "lng" : -121.9237934 
        }, 
        "html_instructions" : "Take the \u003cb\u003eMission Blvd\u003c/b\u003e exit toward \u003cb\u003eCalifornia 238\u003c/b\u003e", 
        "maneuver" : "ramp-right", 
        "polyline" : { 
         "points" : "awbdF|[email protected]@[email protected]@[email protected]@[email protected]" 
        }, 
        "start_location" : { 
         "lat" : 37.5385712, 
         "lng" : -121.927027 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "148 ft", 
         "value" : 45 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 18 
        }, 
        "end_location" : { 
         "lat" : 37.5392255, 
         "lng" : -121.923525 
        }, 
        "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eMission Blvd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eDestination will be on the right\u003c/div\u003e", 
        "maneuver" : "turn-right", 
        "polyline" : { 
         "points" : "i}[email protected]" 
        }, 
        "start_location" : { 
         "lat" : 37.5395679, 
         "lng" : -121.9237934 
        }, 
        "travel_mode" : "DRIVING" 
        } 
       ], 
       "via_waypoint" : [ 
        { 
        "location" : { 
         "lat" : 37.542142, 
         "lng" : -121.9527896 
        }, 
        "step_index" : 3, 
        "step_interpolation" : 0.4860572290564731 
        } 
       ] 
      } 
     ], 
     "overview_polyline" : { 
      "points" : "[email protected]`DxBkFzDiJxDmJvEeLxB_FtAmDdAuBtB}[email protected][[email protected]@gB\\[email protected][email protected]@FkAZoBbA{[email protected]@oB\\[email protected]@[email protected]@[email protected]@[email protected]\\[email protected][email protected]|@[email protected]|[email protected]@[email protected][email protected]}@[email protected]@[email protected]{[email protected]@[email protected]@[email protected]@[email protected]@LbC\\[email protected][email protected][email protected]@[email protected][email protected]@[email protected][email protected]]}@[email protected]_AoB][email protected]{@[email protected]" 
     }, 
     "summary" : "Paseo Padre Pkwy", 
     "warnings" : [], 
     "waypoint_order" : [] 
     }, 
     { 
     "bounds" : { 
      "northeast" : { 
       "lat" : 37.5576351, 
       "lng" : -121.923525 
      }, 
      "southwest" : { 
       "lat" : 37.5392255, 
       "lng" : -121.977954 
      } 
     }, 
     "copyrights" : "Map data ©2013 Google", 
     "legs" : [ 
      { 
       "distance" : { 
        "text" : "4.3 mi", 
        "value" : 6957 
       }, 
       "duration" : { 
        "text" : "12 mins", 
        "value" : 697 
       }, 
       "end_address" : "42701-42753 Mission Boulevard, Fremont, CA 94539, USA", 
       "end_location" : { 
        "lat" : 37.5392255, 
        "lng" : -121.923525 
       }, 
       "start_address" : "Fremont BART Station, Fremont, CA 94536, USA", 
       "start_location" : { 
        "lat" : 37.5576351, 
        "lng" : -121.9749241 
       }, 
       "steps" : [ 
        { 
        "distance" : { 
         "text" : "354 ft", 
         "value" : 108 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 16 
        }, 
        "end_location" : { 
         "lat" : 37.5571031, 
         "lng" : -121.9739004 
        }, 
        "html_instructions" : "Head \u003cb\u003esoutheast\u003c/b\u003e toward \u003cb\u003eWalnut Ave\u003c/b\u003e", 
        "polyline" : { 
         "points" : "[email protected]`A{B" 
        }, 
        "start_location" : { 
         "lat" : 37.5576351, 
         "lng" : -121.9749241 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.4 mi", 
         "value" : 683 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 74 
        }, 
        "end_location" : { 
         "lat" : 37.5518666, 
         "lng" : -121.977954 
        }, 
        "html_instructions" : "Take the 1st \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eWalnut Ave\u003c/b\u003e", 
        "polyline" : { 
         "points" : "{jfdFz_ngVXRzB|A`@[email protected]`@XDBRNHHVR`[email protected]@[email protected]@VRzAdAVR" 
        }, 
        "start_location" : { 
         "lat" : 37.5571031, 
         "lng" : -121.9739004 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.3 mi", 
         "value" : 507 
        }, 
        "duration" : { 
         "text" : "1 min", 
         "value" : 66 
        }, 
        "end_location" : { 
         "lat" : 37.5493906, 
         "lng" : -121.9731305 
        }, 
        "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003ePaseo Padre Pkwy\u003c/b\u003e", 
        "maneuver" : "turn-left", 
        "polyline" : { 
         "points" : "[email protected]@[email protected]|AqD|AwDpA}CfBoE" 
        }, 
        "start_location" : { 
         "lat" : 37.5518666, 
         "lng" : -121.977954 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "1.6 mi", 
         "value" : 2600 
        }, 
        "duration" : { 
         "text" : "3 mins", 
         "value" : 191 
        }, 
        "end_location" : { 
         "lat" : 37.5411851, 
         "lng" : -121.9481001 
        }, 
        "html_instructions" : "Continue straight to stay on \u003cb\u003ePaseo Padre Pkwy\u003c/b\u003e", 
        "maneuver" : "straight", 
        "polyline" : { 
         "points" : "uzddF`{[email protected]@[email protected][email protected]@[email protected]@}@[email protected]@[email protected][email protected]_A^[email protected]@aAP[T][email protected]@V{@[email protected]@[email protected]@[email protected]@[email protected][email protected]@[email protected]@[email protected]}@aA{[email protected]@[email protected]?EL{@[email protected]@[email protected]@iA^[email protected]\\[email protected]@NW" 
        }, 
        "start_location" : { 
         "lat" : 37.5493906, 
         "lng" : -121.9731305 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "0.7 mi", 
         "value" : 1195 
        }, 
        "duration" : { 
         "text" : "2 mins", 
         "value" : 106 
        }, 
        "end_location" : { 
         "lat" : 37.54969699999999, 
         "lng" : -121.9398308 
        }, 
        "html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eDriscoll Rd\u003c/b\u003e", 
        "maneuver" : "turn-left", 
        "polyline" : { 
         "points" : "mgcdFr~hgVOS]YeEsD{BmB_BsAuEoEwAsAuB{[email protected]@MMaBeBsBsBwBsBwAwAoCsCkDgD" 
        }, 
        "start_location" : { 
         "lat" : 37.5411851, 
         "lng" : -121.9481001 
        }, 
        "travel_mode" : "DRIVING" 
        }, 
        { 
        "distance" : { 
         "text" : "1.2 mi", 
         "value" : 1864 
        }, 
        "duration" : { 
         "text" : "4 mins", 
         "value" : 244 
        }, 
        "end_location" : { 
         "lat" : 37.5392255, 
         "lng" : -121.923525 
        }, 
        "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eMission Blvd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eDestination will be on the right\u003c/div\u003e", 
        "maneuver" : "turn-right", 
        "polyline" : { 
         "points" : "s|ddF|[email protected]@}[email protected]}[email protected]@[email protected]@[email protected]`@{@zAaD\\[email protected]@[email protected]_LpG{M`[email protected]@[email protected][[email protected]@@[email protected]{@[email protected]@" 
        }, 
        "start_location" : { 
         "lat" : 37.54969699999999, 
         "lng" : -121.9398308 
        }, 
        "travel_mode" : "DRIVING" 
        } 
       ], 
       "via_waypoint" : [ 
        { 
        "location" : { 
         "lat" : 37.5448008, 
         "lng" : -121.9447476 
        }, 
        "step_index" : 4, 
        "step_interpolation" : 0.4176798920642508 
        } 
       ] 
      } 
     ], 
     "overview_polyline" : { 
      "points" : "[email protected]`DxBkFzDiJxDmJvEeLxB_FtAmDdAuBtB}[email protected][[email protected]@gB\\[email protected][email protected]@FkAZoBbA{[email protected]{EaEmHcHoCuCkGoGoEkEoCsCkDgDdHuNhB{DpC}FfEqI|B}[email protected]@cA`[email protected][email protected]~CsBtAcA" 
     }, 
     "summary" : "Paseo Padre Pkwy and Mission Blvd", 
     "warnings" : [], 
     "waypoint_order" : [] 
     } 
    ], 
    "status" : "OK" 
} 

我使用overview_polyline每個路由對象在JavaScript中看地圖中的多段線。我將使用來自後端python應用程序的API,並且只有在這種情況下,JavaScript纔會進行交叉檢查,以防萬一您想知道爲什麼我不使用JavaScript API。

<html> 
<head> 
<title>Test</title> 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?libraries=geometry&amp;sensor=false"></script> 
<style type="text/css"> 
    #map {width:670px;height:600px;} 
</style> 
<script type='text/javascript'> 
function initialize() { 
    var myLatlng = new google.maps.LatLng(37.557139,-121.975332); 
    var myOptions = { 
     zoom: 12, 
     center: myLatlng, 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
    } 
    var map = new google.maps.Map(document.getElementById("map"), myOptions); 

    // between first two stops - alternate 2 
    var polyLineStr = "[email protected]`DxBkFzDiJxDmJvEeLxB_FtAmDdAuBtB}[email protected][[email protected]@gB\[email protected][email protected]@FkAZoBbA{[email protected]mE{EaEmHcHoCuCkGoGoEkEoCsCkDgDdHuNhB{DpC}FfEqI|B}[email protected]@cA`[email protected][email protected]~CsBtAcA"; 

    var decodedPath = google.maps.geometry.encoding.decodePath(polyLineStr); 
    var decodedLevels = decodeLevels("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"); 

    var setRegion = new google.maps.Polyline({ 
     path: decodedPath, 
     levels: decodedLevels, 
     strokeColor: "#FF0000", 
     strokeOpacity: 1.0, 
     strokeWeight: 2, 
     map: map 
    }); 
} 

function decodeLevels(encodedLevelsString) { 
    var decodedLevels = []; 

    for (var i = 0; i < encodedLevelsString.length; ++i) { 
     var level = encodedLevelsString.charCodeAt(i) - 63; 
     decodedLevels.push(level); 
    } 
    return decodedLevels; 
} 
</script> 
</head> 
<body onload="initialize()"> 
<div id="map"></div> 
</body> 
</html> 

我想我做錯了什麼 - 但不知道是什麼。任何幫助,將不勝感激。這jsfiddle link顯示的行爲。

+0

您是否嘗試過使用人類Web界面進行等效查詢以查看您是否得到相同的結果?如果你這樣做,問題出在Google的數據上,你可以做的事情不多,只是抱怨他們。如果它做了不同的事情,那麼你可以試着找出不同的東西並解決它。 – abarnert

+2

您在編碼折線中有非反斜槓,導致路徑出錯。 – geocodezip

+0

此外,結果似乎有一個更大的問題,而不是它如何到達目的地 - 目的地遠不及你要求的地方。 – abarnert

回答

0

這只是您測試代碼的一個工件。您的字符串字面polyLineStr

var polyLineStr = "[email protected]`DxBkFzDiJxDmJvEeLxB_FtAmDdAuBtB}[email protected][[email protected]@gB\[email protected][email protected]@FkAZoBbA{[email protected]{EaEmHcHoCuCkGoGoEkEoCsCkDgDdHuNhB{DpC}FfEqI|B}[email protected]@cA`[email protected][email protected]~CsBtAcA"; 

...在它的中間一個轉義'\e'。據推測,無論你複製並粘貼它,它只是實際打印的字符串,並且只要在其周圍添加引號就可以將它轉換爲JS文字。但在JS文字中,'\e'表示e,所以反斜槓丟失,導致整個路徑出錯。

解決這個特殊的問題是隻是爲了逃避它:

var polyLineStr = "[email protected]`DxBkFzDiJxDmJvEeLxB_FtAmDdAuBtB}[email protected][[email protected]@gB\\[email protected][email protected]@FkAZoBbA{[email protected]{EaEmHcHoCuCkGoGoEkEoCsCkDgDdHuNhB{DpC}FfEqI|B}[email protected]@cA`[email protected][email protected]~CsBtAcA"; 

那一個個字符改變你撥弄使得它給出正確的結果。

在你的實際代碼中,這個問題可能甚至不會到達,因爲你的源代碼中沒有路徑作爲文字(或者嘗試使用字符串值來產生和評估字符串文字) ;你只需從JSON中獲取它們就可以了。

(有趣的是,如果你想在Python中進行了測試,你就不會注意到了這個問題,因爲'\e'將解析爲\e,而不是僅僅e反正...這將是更加神祕,因爲它止跌直到你運行了一個測試,例如,中間有一個'\n'的測試。)