🛠️DevTools

Kubernetes Config Viewer

Navigate Kubernetes deployment specs, container configurations, and resource limits easily.

Code Examples

Here's how to achieve this in different programming languages:

1// Parse and traverse JSON
2const jsonData = {
3 "apiVersion": "apps/v1",
4 "kind": "Deployment",
5 "metadata": {
6 "name": "nginx-deployment",
7 "labels": {
8 "app": "nginx",
9 "environment": "production"
10 }
11 },
12 "spec": {
13 "replicas": 3,
14 "selector": {
15 "matchLabels": {
16 "app": "nginx"
17 }
18 },
19 "template": {
20 "metadata": {
21 "labels": {
22 "app": "nginx"
23 }
24 },
25 "spec": {
26 "containers": [
27 {
28 "name": "nginx",
29 "image": "nginx:1.21",
30 "ports": [
31 {
32 "containerPort": 80
33 }
34 ],
35 "resources": {
36 "limits": {
37 "cpu": "500m",
38 "memory": "128Mi"
39 },
40 "requests": {
41 "cpu": "250m",
42 "memory": "64Mi"
43 }
44 }
45 }
46 ]
47 }
48 }
49 }
50};
51
52// Access nested values
53function getValue(obj, path) {
54 return path.split('.').reduce((acc, key) => acc?.[key], obj);
55}
56
57// Get all paths in JSON
58function getAllPaths(obj, prefix = '') {
59 const paths = [];
60 for (const [key, value] of Object.entries(obj)) {
61 const path = prefix ? `${prefix}.${key}` : key;
62 paths.push(path);
63 if (typeof value === 'object' && value !== null) {
64 paths.push(...getAllPaths(value, path));
65 }
66 }
67 return paths;
68}
69
70console.log(getAllPaths(jsonData));

More JSON Examples

Related JSON Tools

📚 Learn More