数据数组始终处理为字符串而不是数组 Angular.fromJson

Data Array Always Process to String not Array With Angular.fromJson

我有问题,我确实将字段形式设置为数组。示例:响应中的字段 dfp_interest 是 []。所以,我必须将我的数据设置为数组吗?我做到了,并且在 console.log 中取得了成功。结果类似于 --> ["5","6"] 但是当我在 angular.fromJson 中处理并使用 $http 发送时,我的参数 dfp_interest 是字符串而不是数组。我错了吗 ?给我解决方案还是我做错了?

这是我在API

中发送参数的过程
var a = angular.fromJson({
            "data" : "{\"username\": \"newshubid\", \"data\":{\"_id\": \""+ $scope.id +"\",\"label\": \""+ $scope.label +"\",\"active\": \""+ $scope.active +"\",\"parent_id\": \""+ $scope.parent_id +"\",\"level\": \""+ $scope.level +"\",\"meta_title\": \""+ $scope.meta_title +"\",\"meta_description\": \""+ $scope.meta_description +"\", \"meta_keyword\": \""+ $scope.meta_keyword +"\", \"dfp_interest\": \""+ $scope.tes +"\"}}"
        });

        var param = $.param(a);

        HttpService("POST", url, param, function(response){
            alert(response.message);
        });

这是我的数据数组示例 dfp_interest

$scope.tes = [5, 6];

$scope.testarray = $scope.tes.join("");

angular.fromJson 接受一个字符串参数,也就是说你的代码应该是;

var data = {username: 'newshubid', 
            data: { id: $scope.id, 
                    label: $scope.label, 
                    active: $scope.active,
                    parent_id: $scope.parent_id,
                    level: $scope.level,
                    meta_title: $scope.meta_title,
                    meta_description: $scope.meta_description,
                    meta_keyword: $scope.meta_keyword,
                    dfp_interest: $scope.tes }
           };

    var a = angular.fromJson(JSON.stringify(data));