/usr/bin/jq:参数列表过长,错误提示 [英] /usr/bin/jq: Argument list too long error bash

查看:81
本文介绍了/usr/bin/jq:参数列表过长,错误提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从较大的swagger.json文件内容中替换示例json中的值,并且该值太大.

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 

工作了几天来解决了这个问题,因此无法在此处找到问题. 这是示例json文件:

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
   }
}

  • swagger.json文件-单击此处下载swagger. json文件
    • swagger.json file - Click here to download swagger.json file
    • 这是我使用的命令,它给我一个错误,我作为参数太大.

      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"
      

      任何人都可以帮忙!

      swagger = $(cat swagger.json)

      swagger = $(cat swagger.json)

      推荐答案

      Q并没有明确说明$swagger的设置方式,但似乎最好使用以下方法之一,而不是使用--arg swagger $swagger面向文件的命令行选项,可能类似于:

      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!)

      如果您担心不赞成使用--argfile选项,那么如果您的jq拥有它,则一定使用--slurpfile代替,但是请注意,后一个选项将文件内容包装到JSON数组中,因此您将不得不考虑到这一点.

      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.

      这些选项和其他选项均在 https://stedolan.github的官方文档中进行了简要介绍. .io/jq/manual/

      These and other options are all presented succinctly in the official documentation at https://stedolan.github.io/jq/manual/

      这篇关于/usr/bin/jq:参数列表过长,错误提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆