Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution for https://github.com/Huachao/vscode-restclient/issues/858 #876

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@
"https-proxy-agent": "^2.2.3",
"httpsnippet": "^1.22.0",
"iconv-lite": "^0.4.15",
"json-bigint": "^1.0.0",
"jsonc-parser": "^2.0.2",
"jsonpath-plus": "^0.20.1",
"mime-types": "^2.1.14",
Expand Down
5 changes: 3 additions & 2 deletions src/utils/requestVariableCacheValueProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { HttpResponse } from '../models/httpResponse';
import { ResolveErrorMessage, ResolveResult, ResolveState, ResolveWarningMessage } from "../models/httpVariableResolveResult";
import { MimeUtility } from './mimeUtility';
import { getContentType, getHeader, isJSONString } from './misc';
import JSONbig from 'json-bigint';

const xpath = require('xpath');
const { DOMParser } = require('xmldom');
Expand Down Expand Up @@ -59,7 +60,7 @@ export class RequestVariableCacheValueProcessor {

const contentTypeHeader = getContentType(headers);
if (MimeUtility.isJSON(contentTypeHeader) || (MimeUtility.isJavaScript(contentTypeHeader) && isJSONString(body as string))) {
const parsedBody = JSON.parse(body as string);
const parsedBody = JSONbig.parse(body as string);

return this.resolveJsonHttpBody(parsedBody, nameOrPath);
} else if (MimeUtility.isXml(contentTypeHeader)) {
Expand All @@ -86,7 +87,7 @@ export class RequestVariableCacheValueProcessor {
private static resolveJsonHttpBody(body: any, path: string): ResolveResult {
try {
const result = JSONPath({ path, json: body });
const value = typeof result[0] === 'string' ? result[0] : JSON.stringify(result[0]);
const value = typeof result[0] === 'string' ? result[0] : JSONbig.stringify(result[0]);
if (!value) {
return { state: ResolveState.Warning, message: ResolveWarningMessage.IncorrectJSONPath };
} else {
Expand Down
5 changes: 4 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ const config = {
vscode: "commonjs vscode" // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
},
resolve: { // support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
extensions: ['.ts', '.js']
extensions: ['.ts', '.js'],
alias: {
"bignumber.js$": "bignumber.js/bignumber.js"
}
},
module: {
rules: [{
Expand Down