CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2011
    Posts
    12

    Deserialize JSON file into its parts

    I have a JSON file like seen below...
    I need to read this into is parts....NOTING that I trucated this JSON file quite a bit to just show one record per section


    I need to loop through the "bovaObj" Key and display all the records inside it. For instance there is one here "010033"
    --------I need to eventual write this to a table but writing into individual rows in a text box would be fine
    I then need to Read down into the "result"
    --------WIthin the "Result" key will be 20 or so Keys....as seen below there are "BBA", "County", "HUC12"
    --------I need to read all the records and fields into a table from each of these 3 Keys

    Any thoughts how to read this deep and how to read the multiple Keys in the "result" indivudually? I would want to read the data inside the "data" subkey for each of the 3 keys "BBA", "County", "HUC12"

    Code:
    {"results":[{"paramName":"Result","dataType":"GPString","value":{
        "bovaObj": {
            "010033": [
                161094, 
                "Lepisosteus osseus", 
                "Gar, longnose", 
                999, 
                999, 
                999, 
                999, 
                "[123,223,999]"
            ],
        }, 
        "pythonFinish": "2022-02-23 10:02:42.934000", 
        "pythonStart": "2022-02-23 10:02:14.877000",
        "result": {
            "BBA": {
                "data": [
                    {
                        "AdminComments": null, 
                        "BOVAJSON": "{"040100":["0"],"040248":["0"] }", 
                        "BOVAList": [
                            "040100", 
                            "040248"
                        ]
                    }
                ], 
                "objectIdField": "OBJECTID", 
                "title": "BBA", 
                "url": "https://servicesdev.dwr.virginia.gov/arcgis/rest/services/NeoVafwis/VafwisGuestExtra/FeatureServer/4"
            },
            "County": {
                "data": [
                    {
                        "Acres": 373710.367767, 
                        "Area_SqMi": 583.48797607, 
                        "Area_meter": 1512302714.29, 
                        "BOVAList": [
                            "010033"
                        ]
                    }
                ], 
                "objectIdField": "OBJECTID", 
                "title": "County", 
                "url": "https://servicesdev.dwr.virginia.gov/arcgis/rest/services/NeoVafwis/VafwisGuest/FeatureServer/0"
            }, 
            "HUC12": {
                "data": [
                    {
                        "AreaAcres": 24696.58894066, 
                        "AreaSqKm": 99.94363792, 
                        "BOVAList": [
                            "010131"
                        ]
                    }
    Last edited by jaykappy; February 24th, 2022 at 07:18 AM.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: Deserialize JSON file into its parts

    Please, edit your post to properly format the code snipper(s) with CODE tags.
    Otherwise your codes/script is very hard to read/understand.
    Victor Nijegorodov

  3. #3
    Join Date
    Jun 2011
    Posts
    12

    Re: Deserialize JSON file into its parts

    am new to this and sort of understand the querying JSON with LINQ but still not sure how to get all the way down to say "BBA"

    Very new to this and not sure how to get all the way down to 'BBA' and data:[

    I think I have to walk this entire path?: Results > value > result > BBA > data

    Code:
    {"results":[{"paramName":"Result","dataType":"GPString","value":{
        "bovaObj": {
            "010033": [
                161094, 
                "Lepisosteus osseus", 
                "Gar, longnose", 
                999, 
                999, 
                999, 
                999, 
                "[123,223,999]"
            ],
        }, 
        "pythonFinish": "2022-02-23 10:02:42.934000", 
        "pythonStart": "2022-02-23 10:02:14.877000",
        "result": {
            "BBA": {
                "data": [
                    {
                        "AdminComments": null, 
                        "BOVAJSON": "{"040100":["0"],"040248":["0"] }", 
                        "BOVAList": [
                            "040100", 
                            "040248"
                        ]
                    }

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: Deserialize JSON file into its parts

    Did you try something discussed/suggested here: https://www.google.com/search?q=json...client=gws-wiz
    Victor Nijegorodov

  5. #5
    Join Date
    Jun 2011
    Posts
    12

    Re: Deserialize JSON file into its parts

    Thats the point I have been looking at all of these..thats why I turned to a forum.....I was hoping someone would help with a simple example of how to get to the "BBA":{"data":[]

    Im confused how to walk the whole way down from "results"

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: Deserialize JSON file into its parts

    Well, I had the same problem about three years back in my VC++ project. I've just downloaded some "library" that could parse/encode/decode JSON scripts and then using the https://en.wikibooks.org/wiki/JsonCpp tried to find the functions needed to parse or to write JSON scripts. Kinda Trial-n-Error method!
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured