{"record":{"id":"8fb55ace8d1836c9","repo":"JamesNK/Newtonsoft.Json","slug":"property-0-does-not-exist-on-jobject-8fb55a","errorCode":null,"errorMessage":"Property '{0}' does not exist on JObject.","messagePattern":"Property '(.+?)' does not exist on JObject\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"Src/Newtonsoft.Json/Linq/JsonPath/FieldMultipleFilter.cs","lineNumber":38,"sourceCode":"\n        public override IEnumerable<JToken> ExecuteFilter(JToken root, IEnumerable<JToken> current, JsonSelectSettings? settings)\n        {\n            foreach (JToken t in current)\n            {\n                if (t is JObject o)\n                {\n                    foreach (string name in Names)\n                    {\n                        JToken? v = o[name];\n\n                        if (v != null)\n                        {\n                            yield return v;\n                        }\n\n                        if (settings?.ErrorWhenNoMatch ?? false)\n                        {\n                            throw new JsonException(\"Property '{0}' does not exist on JObject.\".FormatWith(CultureInfo.InvariantCulture, name));\n                        }\n                    }\n                }\n                else\n                {\n                    if (settings?.ErrorWhenNoMatch ?? false)\n                    {\n                        throw new JsonException(\"Properties {0} not valid on {1}.\".FormatWith(CultureInfo.InvariantCulture, string.Join(\", \", Names.Select(n => \"'\" + n + \"'\")\n#if !HAVE_STRING_JOIN_WITH_ENUMERABLE\n                            .ToArray()\n#endif\n                            ), t.GetType().Name));\n                    }\n                }\n            }\n        }\n    }\n}","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/JamesNK/Newtonsoft.Json/blob/4f73e74372445108d2c1bda37b36e6f5e43402e0/Src/Newtonsoft.Json/Linq/JsonPath/FieldMultipleFilter.cs#L20-L56","documentation":"Thrown during JSONPath evaluation when a multiple-field filter (e.g. $['a','b']) runs against a JObject with ErrorWhenNoMatch enabled. Note the code at FieldMultipleFilter.cs:36-39 throws whenever ErrorWhenNoMatch is true on the very first name checked, even if that property exists, because the throw is not gated behind the property being absent (it lacks an else). Practically, any multi-field indexer against a JObject with errorWhenNoMatch=true triggers it.","triggerScenarios":"Calling SelectTokens(\"$.user['first','last']\", errorWhenNoMatch: true) on a JObject. The loop reaches the ErrorWhenNoMatch check and throws after evaluating the first name, regardless of whether that property is present.","commonSituations":"Selecting several optional properties at once with strict error mode; upgrading a single-field path to a multi-field path while keeping errorWhenNoMatch=true.","solutions":["Call SelectTokens with errorWhenNoMatch=false (the default) when using multi-field indexers.","Select each property individually with SelectToken and handle nulls explicitly if you need strict per-field reporting.","Restructure the query to avoid the multi-field form under strict mode."],"exampleFix":"// before\ntoken.SelectTokens(\"$.user['first','last']\", errorWhenNoMatch: true);\n\n// after\ntoken.SelectTokens(\"$.user['first','last']\", errorWhenNoMatch: false);","handlingStrategy":"try-catch","validationCode":"// Avoid strict mode with multi-field indexers\nvar values = token.SelectTokens(\"$.user['first','last']\", errorWhenNoMatch: false);","typeGuard":null,"tryCatchPattern":"try\n{\n    var v = token.SelectTokens(\"$.user['first','last']\", errorWhenNoMatch: true);\n}\ncatch (JsonException ex) when (ex.Message.Contains(\"does not exist on JObject\"))\n{\n    // fall back to per-field selection\n}","preventionTips":["Never combine multi-field indexers with errorWhenNoMatch=true.","Select fields individually when you need per-field absence detection.","Be aware the multi-field strict path throws on the first checked name."],"tags":["jsonpath","field-filter","multi-field"],"analyzedSha":"4f73e74372445108d2c1bda37b36e6f5e43402e0","analyzedAt":"2026-08-07T06:10:08.596Z","schemaVersion":2},"datasetVersion":"2026-08-07T07:17:06.508Z"}