简体   繁体   English

AngularJS中的日期JSON对象JSON

[英]Date json Object json in angularjs

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 我有包含json对象集的json结果。由于json对象为整数值,因此无法获取json对象。这是我的json结果

[{
    "serverdatetime": "2016-09-23 12:21:31",
    "game_result_array": {
        "2016-09-23": [{
            "eShowOnHome": "Yes",
            "dModifiedDate": "2016-09-22",
            "eText": "No",
            "eTodayGame": "No",
            "eDelay": "No",
            "eInvert": "None",
            "eResultOrder": "No",
            "iHGameID": "56444",
            "iGameID": "120",
            "vGameTitle": "Gana M\u00e1s",
            "eStats": "Yes",
            "vUrl": "gana-mas-loteria-nacional",
            "vGameLogo": "https:\/\/s3.amazonaws.com\/cdn.kiskooloterias.com\/dominicanas\/upload\/game_logo\/120\/loteria-nacional-dominicana.jpg",
            "companymodifieddate": "2011-12-19 13:35:54",
            "vCompanyLogo": "https:\/\/s3.amazonaws.com\/cdn.kiskooloterias.com\/dominicanas\/upload\/company\/76\/1373805675_loteria-nacional.jpg",
            "gamemodifieddate": "2016-01-05",
            "iCompanyID": "76",
            "vCompanyName": "Loter\u00eda Nacional",
            "vCompanyurl": "loteria-nacional-resultados",
            "dLastLotteryDate": "2016-09-22",
            "tScore": "28 01 96"
        }]
    },
    "company_ids": "75,76,77,78,84",
    "game_ids": "93,94,95,96,98,127,92,111,120,131,100,101,102,114,117,108,171,172",
    "success": "1",
    "message": "Record found"
}]

Here is the code what i tried 这是我尝试的代码

$http({
                        url : baseUrl,
                        method :'Post',
                        data : param
                    }) 
                    .success(function (result) {  
            $scope.rank =result.game_result_array["2016-09-23"].eShowOnHome;  

}

Is there anyway to get json objects? 反正有获取json对象吗? help me. 帮我。 Thanks in advance 提前致谢

game_result_array is an array , so you need to specify the index . game_result_array是一个数组 ,因此您需要指定索引

This should work fine. 这应该工作正常。

$scope.rank =result.game_result_array["2016-09-23"][0].eShowOnHome;  

You could cast variable that are meant to be integer, Because When Calling From The endpoint, the json with integer types will be shown as strings. 您可以强制转换为整数的变量,因为从端点调用时,具有整数类型的json将显示为字符串。

example below shows how you do that using laravel/lumen 以下示例显示了如何使用laravel / lumen

$x = Data::all();  
  return (int)$x->price;

hope you get the idea 希望你明白

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM