{"record":{"id":"81bbac6a5db23643","repo":"Unity-Technologies/UnityCsReference","slug":"invalid-unicode-escape-char-near","errorCode":null,"errorMessage":"Invalid unicode escape char near {}","messagePattern":"Invalid unicode escape char near (.+?)","errorType":"exception","errorClass":"JSONParseException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/AssetStore/Json.cs","lineNumber":581,"sourceCode":"                        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                }\n                idx = endidx + 1;\n            }\n            if (idx >= len)\n                throw new JSONParseException(\"End of json while parsing while parsing string near \" + PosMsg());\n\n            cur = json[idx];\n\n            Next();\n            return new JSONValue(res);\n        }\n\n        private JSONValue ParseNumber()","sourceCodeStart":563,"sourceCodeEnd":599,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/AssetStore/Json.cs#L563-L599","documentation":"Thrown by the Asset Store JSON parser when a \\uXXXX unicode escape sequence inside a JSON string contains characters that are not valid hexadecimal digits. The parser extracts four characters after \\u and calls Int32.Parse with AllowHexSpecifier; a FormatException from that call triggers this error. It indicates the JSON payload is malformed at the unicode escape position.","triggerScenarios":"Parsing a JSON string containing a \\u escape followed by non-hex characters (e.g. \"\\u00GG\" or \"\\u00\"). Occurs when AssetStoreClient or AssetStoreTooling deserializes a response from the Unity Asset Store server that contains a corrupted or truncated unicode escape sequence.","commonSituations":"Truncated network responses from the Asset Store API, proxy or CDN corruption of JSON payloads, manually-edited or hand-crafted JSON cache files with invalid escapes, character encoding issues where multi-byte sequences are split.","solutions":["Inspect the raw JSON payload at the reported position to find the malformed \\u escape and correct the hex digits.","Clear the Asset Store cache (Library/PackageManager or Editor pref cache) and re-fetch the data to get a clean response.","If the data originates from a server endpoint, verify the server-side JSON serialization handles unicode correctly.","If you control the JSON producer, ensure all unicode codepoints are emitted as valid 4-digit hex \\uXXXX sequences."],"exampleFix":"// before — malformed payload\nstring json = \"{\\\"name\\\": \\\"caf\\\\u00G9\\\"}\";\n// after — valid hex digits\nstring json = \"{\\\"name\\\": \\\"caf\\\\u00e9\\\"}\";","handlingStrategy":"validation","validationCode":"// Pre-validate \\u escape sequences before parsing\nbool HasValidUnicodeEscapes(string json)\n{\n    for (int i = 0; i < json.Length - 5; i++)\n    {\n        if (json[i] == '\\\\' && i + 1 < json.Length && json[i + 1] == 'u')\n        {\n            for (int j = 2; j <= 5; j++)\n            {\n                char c = json[i + j];\n                if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')))\n                    return false;\n            }\n        }\n    }\n    return true;\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var result = JSONParser.SimpleParse(jsonString);\n}\ncatch (JSONParseException ex) when (ex.Message.Contains(\"unicode escape\"))\n{\n    // Log the raw JSON region and re-fetch or sanitize\n    Debug.LogError($\"Malformed unicode escape in JSON: {ex.Message}\");\n}","preventionTips":["Always use a spec-compliant JSON serializer when producing JSON data.","Validate JSON payloads against a JSON schema or linter before parsing.","Cache responses with checksums to detect corruption on re-read.","If consuming external JSON, run it through a strict JSON validator first."],"tags":["json","parsing","asset-store","unicode","malformed-data"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}