0

I have json result which contain set of json objects.I could not get json object because json object is in integer value.Here is my json result

{
    "hotnumber": {
        "1": {
            "Rank": 1,
            "Total": "11",
            "Number": "39",
            "First": "4",
            "Second": "4",
            "Third": "3"
        },
        "2": {
            "Rank": 2,
            "Total": "10",
            "Number": "25",
            "First": "2",
            "Second": "4",
            "Third": "4"
        },
        "3": {
            "Rank": 3,
            "Total": "10",
            "Number": "34",
            "First": "3",
            "Second": "3",
            "Third": "4"
        },
        "4": {
            "Rank": 4,
            "Total": "9",
            "Number": "65",
            "First": "2",
            "Second": "5",
            "Third": "2"
        },
        "5": {
            "Rank": 5,
            "Total": "9",
            "Number": "84",
            "First": "4",
            "Second": "3",
            "Third": "2"
        }
    }
}

Here is the code what i tried

$http({
                        url : baseUrl,
                        method :'Post',
                        data : param
                    }) 
                    .success(function (result) {  
            $scope.rank =result.hotnumber.1.Rank;  

}

Is there anyway to get json objects? help me. Thanks in advance

1
  • 1
    Try $scope.rank =result.hotnumber["1"].Rank; Commented Sep 19, 2016 at 12:57

1 Answer 1

1

for string as a key ("1" is a string), use brackets notation:

$http({
                    url : baseUrl,
                    method :'Post',
                    data : param
                }) 
                .success(function (result) {  
        $scope.rank = result.hotnumber["1"].Rank;  

}

notice hotnumber["1"] instead of hotnumber.1

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

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.