Can't use loaded camVaraible value in a script

I want to use my camVaraible for enableing my custom table paging functionality for this reason i use this logic:

    camForm.on('variables-fetched', function() {
         $scope.jsonData=camForm.variableManager.variableValue('jsonData');
        returnScopeData(camForm.variableManager.variableValue('jsonData')); 
         
        });
     function returnScopeData(data){
     angular.copy(data, jsonData1);
     count=size(data);
    }

    Object.size = function(obj) {
        var size = 0, key;
        for (key in obj) {
            if (obj.hasOwnProperty(key)) size++;
        }
        return size;
    };
    console.log(count);
    console.log(jsonData1);
    var maxSize=$scope.maxSize=count;
    var curPage=$scope.curPage = 1;
    var itemsPerPage=$scope.itemsPerPage = 3;
    var filteredItems=$scope.filteredItems=[];
      $scope.numOfPages = function () {
        return Math.ceil(maxSize / $scope.itemsPerPage);
      };
        $scope.$watch('curPage + numPerPage', function() {
        var begin = (($scope.curPage - 1) * $scope.itemsPerPage),
        end = begin + $scope.itemsPerPage;
        console.log(jsonData1.slice(begin, end));
        $scope.filteredItems = jsonData1.slice(begin, end);
       console.log(filteredItems );
      });

but for some reason jsonData1 isn’t received as a json array and i can’t use .length and slice functioins on it what should i change to use this camVariable data properly?
p.s( my camVariable is a json Array like this [{"name":"ann"},{"name":"bann"},{"name":"kann"},{"name":"Lanny"}];

Hi @Sally,

which data type has your variable jsonData? You can see it in Cockpit.

You could try to create a JSON Javascript Object with JSON.parse().

In your javascript code, you have to change the line

$scope.jsonData=camForm.variableManager.variableValue(‘jsonData’);

to

$scope.jsonData=JSON.parse(camForm.variableManager.variableValue(‘jsonData’));

Hope, it helps.

Cheers
kristin