简体   繁体   中英

insert full path of folder which located locally to json file

this is my json file, i want to insert to 'url' the following path: C:\\Users\\yw1kew\\AppData\\Local\\dmv\\dmv.data\\cameraApp but I want it to be locally to any computer. then i need to start write the path from appdata some way i think how should I do that ?

{
  "version": "0.3.4.0",
  "url": "",
    "productSources": {
        "ps": ""
    }
}

Thanks to answers!!!

     $scope.data=  {
      "version": "0.3.4.0",
      "url": "",
        "productSources": {
            "ps": ""
        }
           }
//updating the url  value
           $scope.data.url="C:\Users\yw1kew\AppData\Local\dmv\dmv.data\cameraApp";

          })

I assume you want the answer in javascript which is implicitly on your tags. Here is how you do it using javascript

var jsonFile = `{
  "version": "0.3.4.0",
  "url": "",
    "productSources": {
        "ps": ""
    }
}`;
var url = "C:\\Users\\yw1kew\\AppData\\Local\\dmv\\dmv.data\\cameraApp";
var jsonObject = JSON.parse(jsonFile);
jsonObject.url = url;
var jsonString = JSON.stringify(jsonObject);

Where jsonString is the final string with the path in it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM