-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
45 lines (44 loc) · 1.76 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE html>
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script>
function* getValues(obj, path)
{
for(const [key, value] of Object.entries(obj))
{
let filteredKey = key.replaceAll(':', '__')
let currentPath = path === null ? filteredKey : `${path}__${filteredKey}`
console.log(currentPath)
if (typeof value == "object" && value !== null)
for(var v of getValues(value, currentPath))
yield v;
else
yield `${currentPath}=${value}`;
}
}
function convert()
{
let input = document.getElementById('input').value
let json = JSON.parse(input)
let values = getValues(json, null)
document.getElementById('output').textContent = [...values].join('\n')
}
</script>
</head>
<body>
<div class="container">
<p class="h1">Convert appsettings json to env</p>
<textarea id="input" class="form-control mb-3" rows="15">
{
"ConnectionStrings": {
"DefaultConnection": "Database=master;Server=(local);Integrated Security=SSPI;"
},
"property": "value"
}
</textarea>
<button class="btn btn-success" onClick="convert()">Convert</button>
<hr>
<textarea class="form-control mb-3" rows="15" readonly id="output"> </textarea>
</div>
</body>
</html>