Re-interpolating a value from jq back into jq

I have an almost-json document in a file named "versions.json" like this:

{
"package_a": {
"version": "1.2.3"
}, "package_b": {
"version": "6.3.0"
}
}


It's input from a third party and I can't change it. What I need to do is interpolate the platform and version into the url. The problem is that that version value comes from the version in the file itself. I can't quite get it in the raw file because it's not actually valid json.

jq -r . versions.json
parse error: Invalid escape at line 5, column 129


I can get this in two passes:

echo '{"platform":"darwin","version":""}' |
jq -f versions.json |
jq -r '{version:.package_a.version,platform:"darwin"}' |
jq -f versions.json |
jq -r '"curl -sSL \(.package_a.url | @sh)"' |
sh


But I'm not happy with the number of pipes and invocations of jq here, and looking to improve this all around. I would prefer a solution that involves a single invocation of jq, if that can be done.