本文整理匯總了TypeScript中JSONPath.parse函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript parse函數的具體用法?TypeScript parse怎麽用?TypeScript parse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了parse函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: GetJsonQueryAt
/**
* Determines the JSON query found at a given position.
* For example, suppressions will use JSON queries to limit the scope of the suppression (e.g. `$..parameters[?(@.name === 'quirkyParam')]`).
*
* @param position The position to look at for a JSON query.
*/
public GetJsonQueryAt(position: Position): string | null {
const lines = this.document.split("\n");
const potentialQuery: string = (lines[position.line].match(/\B\$[.[].+/g) || [])[0];
try {
parse(potentialQuery);
} catch (e) {
return null;
}
return potentialQuery;
}
示例2: catch
const overrideFn = (opt, opts) => {
if (typeof(opts) === 'undefined') {
opts = [];
}
const [path, val] = opt.split('=');
if (typeof(path) === 'undefined' || typeof(val) === 'undefined') {
// tslint:disable-next-line
console.warn('Invalid format for invalid config. Correct is -> jsonpath=value');
return opts;
}
try {
jp.parse(path);
} catch (e) {
// tslint:disable-next-line
console.warn('JSONPath is invalid', e);
}
opts.push({ path, val });
return opts;
};
示例3: parse
export function parse(jsonPath: string): JsonPath {
return jsonpath.parse(jsonPath).map(part => part.expression.value).slice(1);
}