Skip to content

Commit

Permalink
🐛 Fix root array not supported in append.key
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenCMD committed Sep 4, 2022
1 parent 55a238d commit bd7e4e3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/utils/jsonKeyWalker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ObjectIsNotArrayError, ParsingError, TypeUnmatchedError, UnimplementedE

export function appendElemFromKey(obj: JsonObject, key: string, elem: JsonValue, addFirst: boolean): [true] | [false, string] {
try {
walkObjFromJsonKeyPath(obj, new StringReader(key), elem, ['key'], false, addFirst);
walkObjFromJsonKeyPath(obj, new StringReader(key), elem, ['key', 'index'], false, addFirst);
return [true];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
Expand Down Expand Up @@ -64,6 +64,9 @@ function parseObjectFilter(_obj: JsonValue, reader: StringReader, _elem: JsonVal
}

function parseIndex(obj: JsonValue, reader: StringReader, elem: JsonValue, addFirst: boolean): JsonValue {
// Type check
if (!obj || typeof obj !== 'object' || !Array.isArray(obj)) throw new TypeUnmatchedError();

reader.skip().skipWhiteSpace();

if (canParseObjectFilter(reader))
Expand Down

0 comments on commit bd7e4e3

Please sign in to comment.