The resultant string is like this
That seems to be only what you get as an output, e.g. from console.log. It is not a string literal represenation of the string you have, but rather "'" + jsonstring + "'".
If you have used that output as a string literal, and got the parse error from that, you'd rather need to use
'{"@type":"page","count":"6","endIndex":"0","objects":"[{\\"@type\\": \\"viewableObject\\", \\"name\\": \\"Body1\\", \\"objectDbId\\": \\"92\\", \\"objectId\\": \\"allViews\\", \\"resourceGuid\\": \\"c2c06248-53e2-4342-8f8a-df25ef40bd1a\\", \\"type\\": \\"view\\"}, {\\"@type\\": \\"viewableObject\\", \\"name\\": \\"Body1\\", \\"objectDbId\\": \\"150\\", \\"objectId\\": \\"allViews\\", \\"resourceGuid\\": \\"c2c06248-53e2-4342-8f8a-df25ef40bd1a\\", \\"type\\": \\"view\\"}, {\\"@type\\": \\"viewableObject\\", \\"name\\": \\"Body1\\", \\"objectDbId\\": \\"37\\", \\"objectId\\": \\"allViews\\", \\"resourceGuid\\": \\"c2c06248-53e2-4342-8f8a-df25ef40bd1a\\", \\"type\\": \\"view\\"}, {\\"@type\\": \\"viewableObject\\", \\"name\\": \\"Body1\\", \\"objectDbId\\": \\"71\\", \\"objectId\\": \\"allViews\\", \\"resourceGuid\\": \\"c2c06248-53e2-4342-8f8a-df25ef40bd1a\\", \\"type\\": \\"view\\"}, {\\"@type\\": \\"viewableObject\\", \\"name\\": \\"Body1\\", \\"objectDbId\\": \\"85\\", \\"objectId\\": \\"allViews\\", \\"resourceGuid\\": \\"c2c06248-53e2-4342-8f8a-df25ef40bd1a\\", \\"type\\": \\"view\\"}, {\\"@type\\": \\"viewableObject\\", \\"name\\": \\"Body1\\", \\"objectDbId\\": \\"134\\", \\"objectId\\": \\"allViews\\", \\"resourceGuid\\": \\"c2c06248-53e2-4342-8f8a-df25ef40bd1a\\", \\"type\\": \\"view\\"}]","startIndex":"0","totalObjects":"6"}'
Of course, as @FelixKling mentioned in the comments, having JSON strings inside JSON is an antipattern (just as is having JSON in string literals).
> var obj = {"@type":"page","count":"6","endIndex":"0","startIndex":"0","totalObjects":"6"};
[Object]
> var objects = [{"@type": "viewableObject", "name": "Body1", "objectDbId": "92", "objectId": "allViews", "resourceGuid": "c2c06248-53e2-4342-8f8a-df25ef40bd1a", "type": "view"}, {"@type": "viewableObject", "name": "Body1", "objectDbId": "150", "objectId": "allViews", "resourceGuid": "c2c06248-53e2-4342-8f8a-df25ef40bd1a", "type": "view"}, {"@type": "viewableObject", "name": "Body1", "objectDbId": "37", "objectId": "allViews", "resourceGuid": "c2c06248-53e2-4342-8f8a-df25ef40bd1a", "type": "view"}, {"@type": "viewableObject", "name": "Body1", "objectDbId": "71", "objectId": "allViews", "resourceGuid": "c2c06248-53e2-4342-8f8a-df25ef40bd1a", "type": "view"}, {"@type": "viewableObject", "name": "Body1", "objectDbId": "85", "objectId": "allViews", "resourceGuid": "c2c06248-53e2-4342-8f8a-df25ef40bd1a", "type": "view"}, {"@type": "viewableObject", "name": "Body1", "objectDbId": "134", "objectId": "allViews", "resourceGuid": "c2c06248-53e2-4342-8f8a-df25ef40bd1a", "type": "view"}]
[Object]
> obj.objects = JSON.stringify(objects); // first mistake
'[{"@type": "viewableObject", "name": "Body1", "objectDbId": "92", "objectId": "allViews", "resourceGuid": "c2c06248-53e2-4342-8f8a-df25ef40bd1a", "type": "view"}, {"@type": "viewableObject", "name": "Body1", "objectDbId": "150", "objectId": "allViews", "resourceGuid": "c2c06248-53e2-4342-8f8a-df25ef40bd1a", "type": "view"}, {"@type": "viewableObject", "name": "Body1", "objectDbId": "37", "objectId": "allViews", "resourceGuid": "c2c06248-53e2-4342-8f8a-df25ef40bd1a", "type": "view"}, {"@type": "viewableObject", "name": "Body1", "objectDbId": "71", "objectId": "allViews", "resourceGuid": "c2c06248-53e2-4342-8f8a-df25ef40bd1a", "type": "view"}, {"@type": "viewableObject", "name": "Body1", "objectDbId": "85", "objectId": "allViews", "resourceGuid": "c2c06248-53e2-4342-8f8a-df25ef40bd1a", "type": "view"}, {"@type": "viewableObject", "name": "Body1", "objectDbId": "134", "objectId": "allViews", "resourceGuid": "c2c06248-53e2-4342-8f8a-df25ef40bd1a", "type": "view"}]'
> JSON.stringify(obj) // the output you got:
'{"@type":"page","count":"6","endIndex":"0","objects":"[{\"@type\": \"viewableObject\", \"name\": \"Body1\", \"objectDbId\": \"92\", \"objectId\": \"allViews\", \"resourceGuid\": \"c2c06248-53e2-4342-8f8a-df25ef40bd1a\", \"type\": \"view\"}, {\"@type\": \"viewableObject\", \"name\": \"Body1\", \"objectDbId\": \"150\", \"objectId\": \"allViews\", \"resourceGuid\": \"c2c06248-53e2-4342-8f8a-df25ef40bd1a\", \"type\": \"view\"}, {\"@type\": \"viewableObject\", \"name\": \"Body1\", \"objectDbId\": \"37\", \"objectId\": \"allViews\", \"resourceGuid\": \"c2c06248-53e2-4342-8f8a-df25ef40bd1a\", \"type\": \"view\"}, {\"@type\": \"viewableObject\", \"name\": \"Body1\", \"objectDbId\": \"71\", \"objectId\": \"allViews\", \"resourceGuid\": \"c2c06248-53e2-4342-8f8a-df25ef40bd1a\", \"type\": \"view\"}, {\"@type\": \"viewableObject\", \"name\": \"Body1\", \"objectDbId\": \"85\", \"objectId\": \"allViews\", \"resourceGuid\": \"c2c06248-53e2-4342-8f8a-df25ef40bd1a\", \"type\": \"view\"}, {\"@type\": \"viewableObject\", \"name\": \"Body1\", \"objectDbId\": \"134\", \"objectId\": \"allViews\", \"resourceGuid\": \"c2c06248-53e2-4342-8f8a-df25ef40bd1a\", \"type\": \"view\"}]","startIndex":"0","totalObjects":"6"}'
> copied and used as a string literal:
> JSON.parse('{"@type":"page","count":"6","endIndex":"0","objects":"[{\"@type\": \"viewableObject\", \"name\": \"Body1\", \"objectDbId\": \"92\", \"objectId\": \"allViews\", \"resourceGuid\": \"c2c06248-53e2-4342-8f8a-df25ef40bd1a\", \"type\": \"view\"}, {\"@type\": \"viewableObject\", \"name\": \"Body1\", \"objectDbId\": \"150\", \"objectId\": \"allViews\", \"resourceGuid\": \"c2c06248-53e2-4342-8f8a-df25ef40bd1a\", \"type\": \"view\"}, {\"@type\": \"viewableObject\", \"name\": \"Body1\", \"objectDbId\": \"37\", \"objectId\": \"allViews\", \"resourceGuid\": \"c2c06248-53e2-4342-8f8a-df25ef40bd1a\", \"type\": \"view\"}, {\"@type\": \"viewableObject\", \"name\": \"Body1\", \"objectDbId\": \"71\", \"objectId\": \"allViews\", \"resourceGuid\": \"c2c06248-53e2-4342-8f8a-df25ef40bd1a\", \"type\": \"view\"}, {\"@type\": \"viewableObject\", \"name\": \"Body1\", \"objectDbId\": \"85\", \"objectId\": \"allViews\", \"resourceGuid\": \"c2c06248-53e2-4342-8f8a-df25ef40bd1a\", \"type\": \"view\"}, {\"@type\": \"viewableObject\", \"name\": \"Body1\", \"objectDbId\": \"134\", \"objectId\": \"allViews\", \"resourceGuid\": \"c2c06248-53e2-4342-8f8a-df25ef40bd1a\", \"type\": \"view\"}]","startIndex":"0","totalObjects":"6"}')
Parse Error
> // instead, use the string itself:
> var str = JSON.stringify(obj);
> JSON.parse(str)
[Object]
"properly. A better solution would be to not have JSON contain other JSON (objectsshould be encoded an array, not a string containing JSON).