Skip to content

Commit 17714e3

Browse files
committed
fix json example
1 parent 82b9460 commit 17714e3

15 files changed

Lines changed: 20 additions & 16 deletions

File tree

src/targets/node/native.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,17 @@ module.exports = function (source, options) {
5151
case 'application/x-www-form-urlencoded':
5252
if (source.postData.paramsObj) {
5353
code.unshift('var qs = require("querystring");')
54-
code.push(util.format('req.write(qs.stringify(%s));', util.inspect(source.postData.paramsObj)))
54+
code.push(util.format('req.write(qs.stringify(%s));', util.inspect(source.postData.paramsObj, {
55+
depth: null
56+
})))
5557
}
5658
break
5759

5860
case 'application/json':
5961
if (source.postData.jsonObj) {
60-
code.push(util.format('req.write(JSON.stringify(%s));', util.inspect(source.postData.jsonObj)))
62+
code.push(util.format('req.write(JSON.stringify(%s));', util.inspect(source.postData.jsonObj, {
63+
depth: null
64+
})))
6165
}
6266
break
6367

test/fixtures/output/go/native/application-json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func main() {
1111

1212
url := "http://mockbin.com/har"
1313

14-
payload := strings.NewReader("{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }")
14+
payload := strings.NewReader("{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}]}")
1515

1616
req, _ := http.NewRequest("POST", url, payload)
1717

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
HttpResponse<String> response = Unirest.post("http://mockbin.com/har")
22
.header("content-type", "application/json")
3-
.body("{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }")
3+
.body("{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}]}")
44
.asString();

test/fixtures/output/javascript/jquery/application-json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var settings = {
77
"content-type": "application/json"
88
},
99
"processData": false,
10-
"data": "{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }"
10+
"data": "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}]}"
1111
}
1212

1313
$.ajax(settings).done(function (response) {

test/fixtures/output/ocaml/cohttp/application-json.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let uri = Uri.of_string "http://mockbin.com/har" in
66
let headers = Header.init ()
77
|> fun h -> Header.add h "content-type" "application/json"
88
in
9-
let body = Cohttp_lwt_body.of_string "{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }" in
9+
let body = Cohttp_lwt_body.of_string "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}]}" in
1010

1111
Client.call ~headers ~body `POST uri
1212
>>= fun (res, body_stream) ->

test/fixtures/output/php/curl/application-json.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
CURLOPT_TIMEOUT => 30,
1111
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
1212
CURLOPT_CUSTOMREQUEST => "POST",
13-
CURLOPT_POSTFIELDS => "{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }",
13+
CURLOPT_POSTFIELDS => "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}]}",
1414
CURLOPT_HTTPHEADER => array(
1515
"content-type: application/json"
1616
),

test/fixtures/output/php/http1/application-json.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
'content-type' => 'application/json'
99
));
1010

11-
$request->setBody('{"number": 1, "string": "f\\"oo", "arr": [1, 2, 3], "nested": {"a": "b"}, "arr_mix": [1, "a", {"arr_mix_nested": {}}] }');
11+
$request->setBody('{"number":1,"string":"f\\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}]}');
1212

1313
try {
1414
$response = $request->send();

test/fixtures/output/php/http2/application-json.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
$request = new http\Client\Request;
55

66
$body = new http\Message\Body;
7-
$body->append('{"number": 1, "string": "f\\"oo", "arr": [1, 2, 3], "nested": {"a": "b"}, "arr_mix": [1, "a", {"arr_mix_nested": {}}] }');
7+
$body->append('{"number":1,"string":"f\\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}]}');
88

99
$request->setRequestUrl('http://mockbin.com/har');
1010
$request->setRequestMethod('POST');

test/fixtures/output/python/python3/application-json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
conn = http.client.HTTPConnection("mockbin.com")
44

5-
payload = "{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }"
5+
payload = "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}]}"
66

77
headers = { 'content-type': "application/json" }
88

test/fixtures/output/python/requests/application-json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
url = "http://mockbin.com/har"
44

5-
payload = "{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }"
5+
payload = "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}]}"
66
headers = {'content-type': 'application/json'}
77

88
response = requests.request("POST", url, data=payload, headers=headers)

0 commit comments

Comments
 (0)