© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
8 replies
reeeeeee

Get multiple objects in JObject path

I have this kind of XML JOBject
"cust_toLegalEntity": {
  "FOEntity": {
    "externalCode": "202",
    "name": "Test1",
    "startDate": "2022-01-01T00:00:00"
  },
  "FOEntity": {
    "externalCode": "204",
    "name": "Test2",
    "startDate": "2022-01-01T00:00:00"
  }
}
"cust_toLegalEntity": {
  "FOEntity": {
    "externalCode": "202",
    "name": "Test1",
    "startDate": "2022-01-01T00:00:00"
  },
  "FOEntity": {
    "externalCode": "204",
    "name": "Test2",
    "startDate": "2022-01-01T00:00:00"
  }
}


I would like to retrieve a list of external Codes.
I tried with
jobj.SelectToken("cust_toLegalEntity.FOEntity.externalCode)
jobj.SelectToken("cust_toLegalEntity.FOEntity.externalCode)
or with
jobj.SelectTokens("cust_toLegalEntity.FOEntity.externalCode)
jobj.SelectTokens("cust_toLegalEntity.FOEntity.externalCode)
m which works only if there is only 1 FOEntity in the list. If there are more than 1, it returns null.
Any idea how should I specify the path?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Get full paths to executables in %PATH%
C#CC# / help
3y ago
❔ JObject find value
C#CC# / help
3y ago
✅ How to fill JObject?
C#CC# / help
3y ago
✅ Web API Controller Response JObject
C#CC# / help
2y ago