MCPcopy Create free account
hub / github.com/alexbudure/queuedash / parseObjectKey

Method parseObjectKey

packages/ui/src/utils/jsonEditor.ts:231–261  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

229 }
230
231 private parseObjectKey(): string {
232 this.skipWhitespace();
233
234 const char = this.peek();
235
236 if (!char) {
237 throw new JSONishSyntaxError("Expected an object key.");
238 }
239
240 if (char === '"' || char === "'") {
241 return this.parseString(char);
242 }
243
244 if (char === "[") {
245 throw new JSONishSyntaxError("Computed keys are not supported.");
246 }
247
248 if (char === "/") {
249 throw new JSONishSyntaxError("Comments are not supported.");
250 }
251
252 if (char === "`") {
253 throw new JSONishSyntaxError("Template literals are not supported.");
254 }
255
256 if (!this.isIdentifierStart(char)) {
257 throw new JSONishSyntaxError("Expected a quoted string or bare key.");
258 }
259
260 return this.parseIdentifier();
261 }
262
263 private parseString(quote: '"' | "'"): string {
264 this.consume(quote);

Callers 1

parseObjectMethod · 0.95

Calls 5

skipWhitespaceMethod · 0.95
peekMethod · 0.95
parseStringMethod · 0.95
isIdentifierStartMethod · 0.95
parseIdentifierMethod · 0.95

Tested by

no test coverage detected