{"record":{"id":"d1df1c3f681ab052","repo":"JamesNK/Newtonsoft.Json","slug":"invalid-json-schema-type-0","errorCode":null,"errorMessage":"Invalid JSON schema type: {0}","messagePattern":"Invalid JSON schema type: (.+?)","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"Src/Newtonsoft.Json/Schema/JsonSchemaBuilder.cs","lineNumber":485,"sourceCode":"                            throw JsonException.Create(typeToken, typeToken.Path, \"Expected JSON schema type string token, got {0}.\".FormatWith(CultureInfo.InvariantCulture, token.Type));\n                        }\n\n                        type = type | MapType((string)typeToken);\n                    }\n\n                    return type;\n                case JTokenType.String:\n                    return MapType((string)token);\n                default:\n                    throw JsonException.Create(token, token.Path, \"Expected array or JSON schema type string token, got {0}.\".FormatWith(CultureInfo.InvariantCulture, token.Type));\n            }\n        }\n\n        internal static JsonSchemaType MapType(string type)\n        {\n            if (!JsonSchemaConstants.JsonSchemaTypeMapping.TryGetValue(type, out JsonSchemaType mappedType))\n            {\n                throw new JsonException(\"Invalid JSON schema type: {0}\".FormatWith(CultureInfo.InvariantCulture, type));\n            }\n\n            return mappedType;\n        }\n\n        internal static string MapType(JsonSchemaType type)\n        {\n            return JsonSchemaConstants.JsonSchemaTypeMapping.Single(kv => kv.Value == type).Key;\n        }\n    }\n}","sourceCodeStart":467,"sourceCodeEnd":496,"githubUrl":"https://github.com/JamesNK/Newtonsoft.Json/blob/4f73e74372445108d2c1bda37b36e6f5e43402e0/Src/Newtonsoft.Json/Schema/JsonSchemaBuilder.cs#L467-L496","documentation":"Thrown by JsonSchemaBuilder.MapType when the 'type' field of a JSON Schema contains a string that is not in the recognized mapping (object, array, string, number, integer, boolean, null, any). The builder cannot map the token to a JsonSchemaType enum value.","triggerScenarios":"A schema with an unrecognized type value. Examples: JsonSchema.Parse(\"{\\\"type\\\":\\\"double\\\"}\") (should be 'number'), \"{\\\"type\\\":\\\"int\\\"}\" (should be 'integer'), \"{\\\"type\\\":\\\"datetime\\\"}\", or a typo like 'strnig'.","commonSituations":"Using draft-4+ type names not supported by the legacy draft-3 builder; typos; mapping from a different schema dialect; auto-generated schemas using language type names (int, long, double) instead of JSON Schema type names.","solutions":["Use one of the valid JSON Schema type strings: object, array, string, number, integer, boolean, null, any.","Map language types to schema types before emitting (e.g. int/double -> number/integer).","Upgrade to the separate Newtonsoft.Json.Schema package if you need newer draft type semantics."],"exampleFix":"// before\nJsonSchema.Parse(\"{\\\"type\\\":\\\"double\\\"}\");\n// after\nJsonSchema.Parse(\"{\\\"type\\\":\\\"number\\\"}\");","handlingStrategy":"validation","validationCode":"static readonly HashSet<string> ValidTypes = new()\n{ \"object\",\"array\",\"string\",\"number\",\"integer\",\"boolean\",\"null\",\"any\" };\nstatic bool IsValidType(string type) => ValidTypes.Contains(type);","typeGuard":null,"tryCatchPattern":"try { JsonSchema.Parse(json); }\ncatch (JsonException ex) when (ex.Message.StartsWith(\"Invalid JSON schema type\"))\n{ /* map language type names to schema type names before parsing */ }","preventionTips":["Use JSON Schema type names (number, integer, boolean), not language types (double, int, bool).","Validate the 'type' field against the allowed set.","Use Newtonsoft.Json.Schema package for newer drafts."],"tags":["schema","json","jsonschema","validation","type"],"analyzedSha":"4f73e74372445108d2c1bda37b36e6f5e43402e0","analyzedAt":"2026-08-07T06:10:08.596Z","schemaVersion":2},"datasetVersion":"2026-08-07T07:17:06.508Z"}