@@ -2,7 +2,7 @@ const fetch = require('node-fetch');
2
2
const fs = require ( 'fs' ) ;
3
3
const jsonToGo = require ( '../vendor/json-to-go.js' ) ;
4
4
const buildPath = require ( './buildPath' ) ;
5
- const { loadJsonOrYaml , isJsonString, loadConfig} = require ( "./common" ) ;
5
+ const { isJsonString, loadConfig, loadFile , loadJson } = require ( "./common" ) ;
6
6
7
7
let cliOpts
8
8
@@ -89,7 +89,7 @@ function buildOpts(body, cliOpts) {
89
89
if ( isJsonString ( cliOpts . headers ) ) {
90
90
opts . headers = JSON . parse ( cliOpts . headers )
91
91
} else {
92
- opts . headers = loadJsonOrYaml ( cliOpts . headers )
92
+ opts . headers = loadJson ( cliOpts . headers )
93
93
}
94
94
}
95
95
if ( body ) {
@@ -99,12 +99,11 @@ function buildOpts(body, cliOpts) {
99
99
if ( isJsonString ( body ) ) {
100
100
opts . body = body
101
101
} else {
102
- const bodyObj = loadJsonOrYaml ( body )
103
- const sortedBodyObj = Object . keys ( bodyObj ) . sort ( ) . reduce ( ( ret , key ) => {
104
- ret [ key ] = bodyObj [ key ] ;
105
- return ret ;
106
- } , { } ) ;
107
- opts . body = JSON . stringify ( sortedBodyObj )
102
+ const bodyObj = loadFile ( body )
103
+ if ( ! isJsonString ( bodyObj ) ) {
104
+ throw new Error ( `${ body } is not json file.` ) ;
105
+ }
106
+ opts . body = bodyObj
108
107
}
109
108
}
110
109
if ( cliOpts ?. debug ) {
0 commit comments