{"record":{"id":"2bfecc681a898f71","repo":"Unity-Technologies/UnityCsReference","slug":"end-of-json-while-parsing-while-parsing-unicode-ch","errorCode":null,"errorMessage":"End of json while parsing while parsing unicode char near {}","messagePattern":"End of json while parsing while parsing unicode char near (.+?)","errorType":"exception","errorClass":"JSONParseException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/AssetStore/Json.cs","lineNumber":569,"sourceCode":"                        res += '\\b';\n                        break;\n                    case 'f':\n                        res += '\\f';\n                        break;\n                    case 'n':\n                        res += '\\n';\n                        break;\n                    case 'r':\n                        res += '\\r';\n                        break;\n                    case 't':\n                        res += '\\t';\n                        break;\n                    case 'u':\n                        // Unicode char specified by 4 hex digits\n                        string digit = \"\";\n                        if (endidx + 4 >= len)\n                            throw new JSONParseException(\"End of json while parsing while parsing unicode char near \" + PosMsg());\n                        digit += json[endidx + 1];\n                        digit += json[endidx + 2];\n                        digit += json[endidx + 3];\n                        digit += json[endidx + 4];\n                        try\n                        {\n                            int d = System.Int32.Parse(digit, System.Globalization.NumberStyles.AllowHexSpecifier);\n                            res += (char)d;\n                        }\n                        catch (FormatException)\n                        {\n                            throw new JSONParseException(\"Invalid unicode escape char near \" + PosMsg());\n                        }\n                        endidx += 4;\n                        break;\n                    default:\n                        throw new JSONParseException(\"Invalid escape char '\" + ncur + \"' near \" + PosMsg());\n                }","sourceCodeStart":551,"sourceCodeEnd":587,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/AssetStore/Json.cs#L551-L587","documentation":"For a \\u escape, ParseString requires four hex digits; if endidx + 4 >= len (fewer than four characters remain after \\u), it throws JSONParseException (\"End of json while parsing while parsing unicode char near <pos>\"). A separate FormatException-based message (\"Invalid unicode escape char near\") handles the case where four characters exist but are not hex. The doubled 'while parsing while parsing' wording is a typo in the original.","triggerScenarios":"Truncated input ending inside a \\u escape (e.g. \\u00<EOF>); a hand-typed escape with fewer than four hex digits; encoding corruption cutting the sequence.","commonSituations":"Truncated network/file input; copy/paste that cut a unicode escape; manual authoring of \\u sequences.","solutions":["Provide the full four-hex-digit form for every \\u escape (e.g. \\u00E9).\n","Verify input completeness before parsing.","Catch JSONParseException and report the position so the truncated escape can be located."],"exampleFix":"// before\n// { \"city\": \"S\\u00E3\" }   // truncated, only 2 hex digits\n\n// after\n// { \"city\": \"S\\u00E3o Paulo\" }","handlingStrategy":"validation","validationCode":"// Ensure every \\u escape is followed by exactly four hex digits.\n// Generated JSON should satisfy this; validate truncated input by full-body reads.","typeGuard":null,"tryCatchPattern":"try { v = JSON.Parse(json); }\ncatch (JSONParseException ex) { /* position near the truncated \\u sequence */ throw; }\ncatch (System.FormatException) { /* 'Invalid unicode escape char' for non-hex digits */ throw; }","preventionTips":["Always write the full four-hex-digit form for \\u escapes.","Read input to EOF to avoid truncating a \\u sequence.","Use a serializer to emit unicode escapes correctly."],"tags":["json","parse","truncated-input","unicode","string-escape","asset-store","unity"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}