jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [jmeter] FSchumacher commented on a change in pull request #651: Don't assume we have correct JSON at edit time
Date Sat, 13 Mar 2021 17:53:46 GMT

FSchumacher commented on a change in pull request #651:
URL: https://github.com/apache/jmeter/pull/651#discussion_r593780561



##########
File path: src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/util/GraphQLRequestParamUtils.java
##########
@@ -79,27 +76,32 @@ public static boolean isGraphQLContentType(final String contentType) {
      * @throws RuntimeException if JSON serialization fails for some reason due to any runtime
environment issues
      */
     public static String toPostBodyString(final GraphQLRequestParams params) {
-        final ObjectMapper mapper = new ObjectMapper();
-        final ObjectNode postBodyJson = mapper.createObjectNode();
-        postBodyJson.set(OPERATION_NAME_FIELD,
-                JsonNodeFactory.instance.textNode(StringUtils.trimToNull(params.getOperationName())));
-
+        final StringBuilder result = new StringBuilder();

Review comment:
       I don't think, that it will happily generate invalid JSON formatted Strings (my shallow
testing and searching has not been successful here).
   
   The use case I try to enable is to generate a JSON structure like
   ```js
   { "id": ${my_var} }
   ```
   which looks like JSON, but is not. Note the *missing* quotes around the JMeter var. This
is needed, when `my_var` contains a number value. (Bugzilla Id: 65108)
   At *runtime* JMeter will replace the var to generate a valid JSON structure `{ "id": 42
}` when `my_var` has the value `42`.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message