I have ruby code which generate JSON of k8s images
old_versions_json = "[]"
versions_list = JSON.parse(old_versions_json)
versions_list.push("#{namespace}")
c = versions_list.find { |h| h['name'] == name }
# If the service doesn't exist in the configmap yet, add it
if c.nil?
puts("[WARNING] service #{name}:#{version} is not present in the configmap. Adding it.")
versions_list.push({ "name" => name, "version" => version })
end
This is how the JSON structure is coming now.
[
"medusa-dev",
{
"name": "pdtk/gravity-device-data-service",
"version": "3d-dev-1.0.29"
},
{
"name": "pdtk/medusa_dooku",
"version": "3d-dev-1.1.11"
}
]
expected output
{
"medusa-dev": [
{
"name": "pdtk/gravity-device-data-service",
"version": "3d-dev-1.0.29"
},
{
"name": "pdtk/medusa_dooku",
"version": "3d-dev-1.1.11"
}
]
}
what am I doing wrong here?
old_versions_json? If it is just empty array, why did you parse it? If it is some really JSON please add it to the question