none
Get count of JOBJECT child RRS feed

  • Question

  • I have the following JOBJECT that I am able to access via select token.

               string Lat = (string)jsonParse.SelectToken($"features[0].geometry.coordinates.[0].[0].[0]");

    I would like to get the count of the 2nd [0] indexed field:

    This code abends on execution:

     int countLat = jsonParse["features[0].geometry.coordinates[0]"].Count();

    What is the proper syntax to get the count of second indexed value??

    Thanks in Advance

    Saturday, September 8, 2018 10:42 PM

Answers

  • Didn't you want jsonParse.SelectToken($"features[0].geometry.coordinates[0]).Count();  ?

    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    • Marked as answer by DDL19 Monday, September 10, 2018 1:07 PM
    Monday, September 10, 2018 4:58 AM

All replies

  • Didn't you want jsonParse.SelectToken($"features[0].geometry.coordinates[0]).Count();  ?

    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    • Marked as answer by DDL19 Monday, September 10, 2018 1:07 PM
    Monday, September 10, 2018 4:58 AM
  • Hi DDL19,

    I would suggest that you could share the value of JOjbect named features and what field you want to retrieve, it will be beneficial to resolve the issue.

    In addition, here is sample about how to use SelectToken with LINQ and SelectToken with JSONPath for your reference. 

    https://www.newtonsoft.com/json/help/html/SelectToken.htm

    In addition, since the issue is more related to JSON.net, you could post your issue on the stackoverflow with flag json.net for suitable support.

    https://stackoverflow.com/questions/tagged/json.net

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 10, 2018 6:16 AM
    Moderator