Automation and Artificial Intelligence

A JSON file must store the literal path C:\temp\new without introducing tabs or newlines. Which document preserves that exact value when parsed?

Show the answer

Correct answerC. {"path":"C:\\temp\\new"}

AWhy not this: The escape sequences decode to a tab and a newline rather than literal backslashes.

BWhy not this: Forward slashes remain forward slashes, so the parsed value differs from the required path.

CWhy this is right: Each escaped backslash decodes to one literal backslash, preserving the exact path.

DWhy not this: Each group of four backslashes decodes to two, producing extra backslashes in the path.

A literal backslash is encoded as \\ within a JSON string. The sequences \t and \n instead decode to a tab and a newline, so a document can be valid JSON yet store the wrong path.