I want to replace the value in sample json from larger swagger.json file content and it is too large.
Error:
/usr/bin/jq: Argument list too long error bash
worked to solve this issue for a few days and cannot identify the issue here. this is the sample json file:
{
"name": "",
"description": "",
"context": "",
"version": "",
"provider": "cbs",
"apiDefinition": "",
"wsdlUri": null,
"responseCaching": "Disabled",
"cacheTimeout": 300,
"destinationStatsEnabled": false,
"isDefaultVersion": true,
"transport": [
"http",
"https"
],
"tags": ["PROVIDER_","MIFE"],
"tiers": ["Unlimited","Default","Silver","Subscription","Gold","Premium","Bronze"],
"maxTps": {
"sandbox": 5000,
"production": 1000
},
"visibility": "PUBLIC",
"visibleRoles": [],
"endpointConfig": "",
"endpointSecurity": {
"username": "user",
"type": "basic",
"password": "pass"
},
"gatewayEnvironments": "Production and Sandbox",
"sequences": [],
"subscriptionAvailability": null,
"subscriptionAvailableTenants": [],
"businessInformation": {
"businessOwnerEmail": "BUSINESSOWNEREMAIL_",
"technicalOwnerEmail": "TECHNICALOWNEREMAIL_",
"technicalOwner": "TECHNICALOWNER_",
"businessOwner": "BUSINESSOWNER_"
},
"corsConfiguration": {
"accessControlAllowOrigins": ["*"],
"accessControlAllowHeaders": [
"authorization",
"Access-Control-Allow-Origin",
"Content-Type",
"SOAPAction"
],
"accessControlAllowMethods": [
"GET",
"PUT",
"POST",
"DELETE",
"PATCH",
"OPTIONS"
],
"accessControlAllowCredentials": false,
"corsConfigurationEnabled": false
}
}
this is the command i using and it give me a error which i as arguments too large.
swagger = $(cat swagger.json)
jq -r --arg swagger "$swagger" '.apiDefinition = $swagger' <<<"$json"
Can anyone please help!
swagger = $(cat swagger.json)
The Q does not explicitly say how $swagger
has been set, but it would seem that rather than using --arg swagger $swagger
you would be better off using one of the file-oriented command-line options, perhaps along the lines of:
--argfile swagger swagger.json
There are many alternatives, but to explore these sensibly here, it would be best if you provided at least one complete but very TINY example. (The example does NOT have to illustrate the "Argument list too long" error!)
If you are worried that the --argfile
option is deprecated, then by all means use --slurpfile
instead if your jq
has it, but note that the latter option wraps the file contents into a JSON array, so you would have to take that into account.
These and other options are all presented succinctly in the official documentation at https://stedolan.github.io/jq/manual/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With