File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -39,16 +39,34 @@ var keyValueToJson = &cobra.Command{
39
39
continue
40
40
}
41
41
42
+ // Skip comments
42
43
if strings .HasPrefix (e , "#" ) || strings .HasPrefix (e , "//" ) {
43
44
continue
44
45
}
45
46
47
+ // Skip lines without "="
46
48
if ! strings .Contains (e , "=" ) {
47
49
continue
48
50
}
49
51
52
+ // Split the line by "="
50
53
parts := strings .Split (e , "=" )
51
- m [strings .TrimSpace (parts [0 ])] = strings .TrimSpace (parts [1 ])
54
+
55
+ var value string
56
+
57
+ // If the value contains "=" then join the parts otherwise take the second part
58
+ if len (parts ) > 2 {
59
+ value = strings .Join (parts [1 :], "=" )
60
+ } else {
61
+ value = parts [1 ]
62
+ }
63
+
64
+ // Remove " and ' from the value string
65
+ value = strings .Trim (value , "\" " )
66
+ value = strings .Trim (value , "'" )
67
+
68
+ // Add the key-value pair to the map
69
+ m [strings .TrimSpace (parts [0 ])] = strings .TrimSpace (value )
52
70
}
53
71
jsonString , _ := json .MarshalIndent (m , "" , " " )
54
72
You can’t perform that action at this time.
0 commit comments