【问题标题】:How to escape pound symbol in the json post body for jmeter如何在 jmeter 的 json 帖子正文中转义磅符号
【发布时间】:2018-04-18 10:57:11
【问题描述】:

我有一个端点,它的帖子正文为 json,但它给出了异常作为 json 解析异常,而文本在 jmeter 中有磅符号('£')但是它在邮递员中工作正常。

{"value":[{"text":"Paying £45 a month ok for you?"}]}

如果我删除 £ 符号,那么它在 jmeter 中可以正常工作。

我已经在 J​​meter 中提到了 header 作为 Content-Type: application/json。

请问如何处理 json 正文中的磅符号?

【问题讨论】:

    标签: json jmeter jmeter-plugins jmeter-3.2


    【解决方案1】:
    1. 尝试修改 Content-Type 标头,使其看起来像:

      application/json; charset=UTF-8
      
    2. 确保使用相同的编码运行 JMeter,将下一行添加到 system.properties 文件:

      file.encoding=UTF-8
      
    3. 在 HTTP 请求采样器中将 Content-Encoding 设置为 UTF-8,或者在 HTTP Request Defaults 中设置更好,这样您就不必为所有采样器单独执行此操作。

    4. 最后,鉴于您的请求在 Postman 中有效,您应该能够使用 JMeter 的 HTTP(S) test Script Recorder 记录它。

    5. 还可以考虑升级到最新的 JMeter 版本,截至目前为 JMeter 4.0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-07
      相关资源
      最近更新 更多