[英]How to access values within the JSON object?
//file.json
{
endpoint1:"localhost:8080/user1",
endpoint2:"localhost:8080/user2",
endpoint3:"localhost:8080/user3",
endpoint4:"localhost:8080/user4",
.....
}
在此代碼中, localhost:8080 重復。 如何將 localhost:8080 存儲在單獨的變量中並在 JSON 文件中訪問它? 是否有可能,如果不是,替代方案是什么?
Example :
let end="localhost:8080"
within the json file, how to access the varaible let,
{
endpoint1:end+"/user1",
.......
}
明天如果我必須更改本地主機,那么我必須更改 JSON 文件中的所有值。 如果我想出一個公共變量,我只需要單獨更改它......
//file.json
{
endpoint1:"localhost:8080/user1",
endpoint2:"localhost:8080/user2",
endpoint3:"localhost:8080/user3",
endpoint4:"localhost:8080/user4",
.....
}
在此代碼中, localhost:8080 重復。 如何將 localhost:8080 存儲在單獨的變量中並在 JSON 文件中訪問它? 是否有可能,如果不是,替代方案是什么?
Example :
let end="localhost:8080"
within the json file, how to access the varaible let,
{
endpoint1:end+"/user1",
.......
}
明天如果我必須更改本地主機,那么我必須更改 JSON 文件中的所有值。 如果我想出一個公共變量,我只需要單獨更改它......
//file.json
{
endpoint1:"localhost:8080/user1",
endpoint2:"localhost:8080/user2",
endpoint3:"localhost:8080/user3",
endpoint4:"localhost:8080/user4",
.....
}
在此代碼中, localhost:8080 重復。 如何將 localhost:8080 存儲在單獨的變量中並在 JSON 文件中訪問它? 是否有可能,如果不是,替代方案是什么?
Example :
let end="localhost:8080"
within the json file, how to access the varaible let,
{
endpoint1:end+"/user1",
.......
}
明天如果我必須更改本地主機,那么我必須更改 JSON 文件中的所有值。 如果我想出一個公共變量,我只需要單獨更改它......
//file.json
{
endpoint1:"localhost:8080/user1",
endpoint2:"localhost:8080/user2",
endpoint3:"localhost:8080/user3",
endpoint4:"localhost:8080/user4",
.....
}
在此代碼中, localhost:8080 重復。 如何將 localhost:8080 存儲在單獨的變量中並在 JSON 文件中訪問它? 是否有可能,如果不是,替代方案是什么?
Example :
let end="localhost:8080"
within the json file, how to access the varaible let,
{
endpoint1:end+"/user1",
.......
}
明天如果我必須更改本地主機,那么我必須更改 JSON 文件中的所有值。 如果我想出一個公共變量,我只需要單獨更改它......
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.