0

I have a nested JSON object that I am having trouble parsing. The stuucture is as follows

    {
  "status": {
    "version": "1.0.0",
    "code": 0,
    "msg": "SuccessWithResult",
    "total": 1,
    "page": 1,
    "pagesize": 10
  },
  "property": [
    {
      "identifier": {
        "obPropId": 2511639610001,
        "fips": "10001",
        "apn": "11701014062800000",
        "apnOrig": "1-17-010.14-06-28.00-000"
      },
      "lot": {
        "depth": 110,
        "frontage": 22,
        "lotnum": "28",
        "lotsize1": 600,
        "lotsize2": 2614
      },
      "area": {
        "countrysecsubd": "Kent County",
        "countyuse1": "P",
        "muncode": "17",
        "munname": "DUCK CREEK",
        "subdname": "WOODLAND MANOR PH I",
        "taxcodearea": "17"
      },
      "address": {
        "country": "US",
        "countrySubd": "DE",
        "line1": "468 SEQUOIA DR",
        "line2": "SMYRNA, DE 19977",
        "locality": "Smyrna",
        "matchCode": "ExaStr",
        "oneLine": "468 SEQUOIA DR, SMYRNA, DE 19977",
        "postal1": "19977",
        "postal2": "2542",
        "postal3": "C003"
      },
      "location": {
        "accuracy": "Street",
        "elevation": 0,
        "latitude": "39.302769",
        "longitude": "-75.594399",
        "distance": 0,
        "geoid": "MT30001363,PL1067310,RS0000330264,SD67611,SS155012,SS198222,SS201397,SS201759"
      },
      "summary": {
        "absenteeInd": "OWNER OCCUPIED",
        "propclass": "Apartment",
        "propsubtype": "SINGLE FAMILY",
        "proptype": "APARTMENT",
        "yearbuilt": 2006,
        "propLandUse": "APARTMENT"
      },
      "utilities": {
        "coolingtype": "TYPE UNKNOWN",
        "heatingtype": "WARM AIR",
        "wallType": "ALUMINUM"
      },
      "building": {
        "size": {
          "bldgsize": 2145,
          "grosssize": 0,
          "grosssizeadjusted": 0,
          "groundfloorsize": 0,
          "livingsize": 1738,
          "sizeInd": "LIVING SQFT ",
          "universalsize": 1738
        },
        "rooms": {
          "bathfixtures": 10,
          "baths1qtr": 0,
          "baths3qtr": 0,
          "bathscalc": 3,
          "bathsfull": 2,
          "bathshalf": 1,
          "bathstotal": 3,
          "beds": 3,
          "roomsTotal": 6
        },
        "interior": {
          "bsmtsize": 715,
          "bsmttype": "UNFINISHED",
          "fplccount": 0
        },
        "construction": {
          "condition": "GOOD",
          "wallType": "ALUMINUM"
        },
        "parking": {
          "prkgSize": 0,
          "prkgSpaces": "0"
        },
        "summary": {
          "archStyle": "TYPE UNKNOWN",
          "bldgsNum": 1,
          "bldgType": "SINGLE FAMILY",
          "levels": 2,
          "storyDesc": "SINGLE FAMILY",
          "unitsCount": "0",
          "yearbuilteffective": 0
        }
      },
      "vintage": {
        "lastModified": "2015-4-3",
        "pubDate": "2015-5-9"
      }
    }
  ]
}

To access the data I am using

     $.ajax({
         type: "get",
         dataType: 'json',
         url: "https://search.onboard-apis.com/propertyapi/v1.0.0/property/detail?address1=7580%20Preservation%20Dr&address2=Sarasota%2C%20FL",
         beforeSend: function (request) {
             request.setRequestHeader("apikey", 'xxxxxxxxxxxxxxxxxxxx');
         },
         success: function (result) {
             $.each(result, function (index, object) {
                 $.each(object, function (i, o) {
                     console.log(i + " = " + o);
                 })
             })

         },
         error: function (xmlHttpRequest, textStatus, errorThrown) {
             output = '<div class="error">' + textStatus + ' ' + errorThrown + '</div>';
         }
     });

However, I am only getting the following output.

version = 1.0.0
code = 0
msg = SuccessWithResult
total = 1
page = 1
pagesize = 10
0 = [object Object]

What I would like to do is be able to Get the property data so I can pull out specific key/values from the property node.

Any help would be greatly appreciated.

7
  • 1
    You don't have any JSON ? Commented Mar 4, 2016 at 17:22
  • In the jquery, there is a function getJSON() Commented Mar 4, 2016 at 17:23
  • 1
    Instead of that strange nested loop, just console.log(result). Commented Mar 4, 2016 at 17:31
  • @Tomalak I am just trying to get the data that is returned from from the part of the response that contains property details not the whole response. Right now I am getting two objects Property and Status. I want to access the parts of the response with only property details like below "address": { "country": "US", "line1": "468 SEQUOIA DR", "line2": "SMYRNA, DE 19977", "oneLine": "468 SEQUOIA DR, SMYRNA, DE 19977", "postal1": "19977", So I can write out to a page the address details. Commented Mar 4, 2016 at 17:42
  • I know what you are trying. My suggestion was that you log the response directly so you can see its structure and figure out the correct path to access the parts you need. Commented Mar 4, 2016 at 17:44

2 Answers 2

1

"property" is an array itself so you'd need another iteration through there, and then a second iteration to scan the objects returned.

If you are trying to go after a specific property, there are easier ways. You can use result.property[0].area.munname;

To access a munname directly.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks I have tried that I just keep getting undefined in the console.
success: function (result) { console.log(result.property[0].area.munname) },
0

I actually got what I needed using

             console.log(result.property[0].address.oneLine)
             console.log(result.property[0].location.latitude)

thanks for all the help who contributed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.