0

It's been a while since I've done some heavy coding and I am new to Javascript and jQuery and was just wondering the best way to access different parts of the data in this JSON array. Please go easy on me, I'm a bit confused!

UPDATE: I am trying to access the "short_name" property a couple of lines down using this code:

var name = ["com.example.myfile:givers"]["com.example.myfile:Provider"].short_name;

However I am having no luck!

{
  "com.example.myfile:givers": [
    {
      "com.example.myfile:Provider": {
        "last_authentication_at": "2014-11-13T16:57:47Z",
        "created_at": "2013-11-10T02:23:57Z",
        "updated_at": "2014-04-27T16:47:21Z",
        "short_name": "Kelly K.",
        "com.example.myfile:Account": {
          "id": 1,
          "uuid": "6543jkn-32kjbkbj-sfmnsdf"
        },
        "com.example.myfile:Attributes": [
          {
            "key": "age",
            "value": 33
          },
          {
            "key": "comfortable",
            "value": true
          },
          {
            "key": "gender",
            "value": "female"
          },
          {
            "key": "clean",
            "value": false
          }
        ],
        "com.example.myfile:Education": {
          "certification_level": "some_college",
          "currently_attending": true,
          "discipline": {
            "major": "example"
          },
          "graduation_year": null,
          "school_name": "University"
        },
        "com.example.office:Position": {
          "latitude": 91.8,
          "longitude": -27.6,
          "city": "dublin",
          "country": "IRE"
        },
        "com.example.myfile:trophies": [
          2
        ],
        "com.example.myfile:Qualifications": [

        ],
        "com.example.myfile:job": {
          "job_additional_work": [
            "meal_preparation",
            "laundry",
            "light_housekeeping"
          ],
          "job_age_experience": [
            "first_year",
            "mechanic",
            "chef",
            "engineers",
            "library"
          ],
          "willing_to_drive_friends": false,
          "work_with_others": true,
          "years_of_experience": 5,
          "com.example.myfile:job.profession": {
            "description": " example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example",
            "distance_willing_to_travel": {
              "unit": "km",
              "value": 5
            },
            "simultaneous_welfare_recipients": 4,
            "title": null,
            "transportation_access": false,
            "com.example.payment_rate:Range.job": {
              "currency_code": "euro",
              "exponent": -2,
              "max_hexa_value": 1300,
              "min_hexa_value": 900,
              "rate_increase_per_taker_hexa_value": null,
              "unit": "hour"
            },
            "com.example.myfile:Rating": {
              "count": 1,
              "score": 5
            },
            "com.example.myfile:Availability.General": {
              "available_after_school": true,
              "available_before_school": true,
              "available_daytime": "yes",
              "available_short_notice": true,
              "availability_schedule": {
                "early_morning": [
                  "monday",
                  "tuesday",
                  "wednesday",
                  "thursday",
                  "friday"
                ],
                "late_morning": [
                  "monday",
                  "tuesday",
                  "wednesday",
                  "thursday",
                  "friday",
                  "saturday"
                ],
                "early_afternoon": [
                  "monday",
                  "tuesday",
                  "wednesday",
                  "thursday",
                  "friday",
                  "saturday"
                ],
                "late_afternoon": [
                  "monday",
                  "tuesday",
                  "wednesday",
                  "thursday",
                  "friday",
                  "saturday"
                ]
              },
              "valid_until": "2016-09-28B00:00:00X"
            }
          },
          "com.example.myfile:housework": {
            "subjects": null,
            "types": null
          },
          "com.example.myfile:job.builder": {
            "description": " example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example",
            "distance_willing_to_travel": {
              "unit": "km",
              "value": 5
            },
            "live_in_provider": false,
            "title": null,
            "transportation_access": false,
            "transport_welfare_taker_to_job_office": null,
            "simultaneous_welfare_recipients": 4,
            "com.example.myfile:Availability.builder": {
              "employment_duration": null,
              "employment_type": null,
              "availability_schedule": null,
              "short_notice": true,
              "start_date": null,
              "start_date_flexible": null,
              "valid_until": "2014-01-19T20:32:46Z"
            },
            "com.example.payment_rate:Range.job": {
              "currency_code": "euro",
              "exponent": -2,
              "max_hexa_value": 1600,
              "min_hexa_value": 1300,
              "rate_increase_per_taker_hexa_value": null,
              "unit": "hour"
            },
            "com.example.myfile:Rating": {
              "count": 0,
              "score": 0
            }
          },
          "com.example.myfile:Picture": {
            "cropped": "https:\/\/example.net\/static\/img\/userphoto\/28\/70\/35\/4_m.png",
            "original": "https:\/\/example.net\/static\/img\/userphoto\/28\/70\/35\/4_m.png"
          }
        },
        "com.example.office:Proximity": {
          "distance": 0.353639171,
          "unit": "km"
        },
        "_links": {
          "givers": {
            "href": "\/givers"
          }
        }
      }
    },
    {
      "com.example.myfile:Provider": {
        "last_authentication_at": "2016-06-16T66:60:566Z",
        "created_at": "2016-06-16T66:60:566Z",
        "updated_at": "2016-06-16T66:60:566Z",
        "short_name": "Api P.",
        "com.example.myfile:Account": {
          "id": 2,
          "uuid": "6543jkn-32kjbkbj-sfmnsdf"
        },
        "com.example.myfile:Attributes": [
          {
            "key": "age",
            "value": 32
          },
          {
            "key": "sound",
            "value": true
          },
          {
            "key": "gender",
            "value": "female"
          },
          {
            "key": "clean",
            "value": true
          }
        ],
        "com.example.myfile:Education": {
          "certification_level": null,
          "currently_attending": null,
          "discipline": {
            "major": null
          },
          "graduation_year": null,
          "school_name": null
        },
        "com.example.office:Position": {
          "latitude": 41.9,
          "longitude": -87.6,
          "city": "dublin",
          "country": "IRE"
        },
        "com.example.myfile:trophies": [
          {
            "badge_name": "simpleton"
          }
        ],
        "com.example.myfile:Qualifications": [

        ],
        "com.example.myfile:job": {
          "job_additional_work": null,
          "job_age_experience": [
            "mechanic"
          ],
          "willing_to_drive_friends": null,
          "work_with_others": true,
          "years_of_experience": 2,
          "com.example.myfile:job.profession": {
            "description": " example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example example",
            "distance_willing_to_travel": {
              "unit": "km",
              "value": 12
            },
            "simultaneous_welfare_recipients": 1,
            "title": "profession in dublin, IRE",
            "transportation_access": true,
            "com.example.payment_rate:Range.job": {
              "currency_code": "euro",
              "exponent": -2,
              "max_hexa_value": 1200,
              "min_hexa_value": 1000,
              "rate_increase_per_taker_hexa_value": 1200,
              "unit": "hour"
            },
            "com.example.myfile:Rating": {
              "count": 0,
              "score": 0
            },
            "com.example.myfile:Availability.General": {
              "available_after_school": true,
              "available_before_school": true,
              "available_daytime": "yes",
              "available_short_notice": true,
              "availability_schedule": {
                "early_morning": [
                  "sunday"
                ]
              },
              "valid_until": "2016-49-14T40:04:44Z"
            }
          },
          "com.example.myfile:housework": {
            "subjects": null,
            "types": null
          },
          "com.example.myfile:SpecialNeeds": {
            "provides_special_needs": true
          }
        },
        "com.example.office:Proximity": {
          "distance": 5.689440379,
          "unit": "km"
        },
        "_links": {
          "givers": {
            "href": "\/givers"
          }
        }
      }
    }
  ],
  "_links": {
    "self": {
      "href": "\/givers?worktype=profession&from=0&lat=60.1231157&long=-98.540204&radius=35&size=10"
    },
    "next": {
      "href": "\/givers?worktype=profession&from=5&lat=60.1231157&long=-98.540204&radius=35&size=10"
    }
  }
}
ThemuRR
  • 61
  • 1
  • 13
  • i think you should post your attempts and also mention what you want to do – guradio Jan 21 '16 at 02:15
  • Way too broad a question as it currently stands. Review the duplicate question/tutorial thoroughly and when you get something started and it's not working bring it back here with a new question and real code. Note that you have proprty names with special characters in them that means you need to use `[]` notation for almost all of them – charlietfl Jan 21 '16 at 02:28
  • @guradio I added an example of a property I am trying to access and also my attempt! – ThemuRR Jan 24 '16 at 23:19

0 Answers0