在请求正文中用JSON对象替换单个参数

时间:2019-07-02 21:56:19

标签: paw-app

我有一个内置于PAW中的请求,其中包含一个接受geoJSON的geometry参数。

## My API
curl -X "POST" "https://myapi.com" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "end_time": "2019-07-02T15:51:57-07:00",
  "buffer": "1",
  "geometry": "{\\n  \\"type\\": \\"Polygon\\",\\n  \\"coordinates\\": [\\n    [\\n      [\\n        -80.587420463562,\\n        37.19727912944858\\n      ],\\n      [\\n        -80.59274196624756,\\n        37.19543313914121\\n      ],\\n      [\\n        -80.59038162231444,\\n        37.19167264889216\\n      ],\\n      [\\n        -80.58094024658203,\\n        37.19396315161421\\n      ],\\n      [\\n        -80.58115482330322,\\n        37.196766358890955\\n      ],\\n      [\\n        -80.587420463562,\\n        37.19727912944858\\n      ]\\n    ]\\n  ]\\n}",
  "max_altitude_agl": 60.96,
  "start_time": "now"
}'

我以前只是粘贴一个字符串化的geojson字符串,如上所示,但这包括很多转义并且通常看起来很丑。我宁愿将geojson作为嵌套对象正确输入。但是,在PAW中输入此代码非常繁琐,因此我希望能够复制geojson字符串并将PAW格式化为嵌套对象。

我可以通过右键单击-> Paste and Replace JSON使其工作,但这将替换所有json,而我只希望替换单个参数(geojson)。我什至可以单击该参数,它仍然会像这样替换所有内容:

## My API
curl -X "POST" "https://myapi.com" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "type": "Polygon",
  "coordinates": [
    [
      [
        -80.587420463562,
        37.19727912944858
      ],
      [
        -80.5927419662476,
        37.19543313914121
      ],
      [
        -80.5903816223144,
        37.19167264889216
      ],
      [
        -80.580940246582,
        37.19396315161421
      ],
      [
        -80.5811548233032,
        37.19676635889095
      ],
      [
        -80.587420463562,
        37.19727912944858
      ]
    ]
  ]
}'

如何仅替换单个参数并使PAW正确将字符串转换为对象?

0 个答案:

没有答案