I have a table with fields
int id|text title|text content|int articleCommentCount|
When I access the json url /articles.json I get something like
{
"announcements": [
{
"id": 2,
"title":"title",
"articleCommentCount": 16 //Notice value is an int
}
]
}
Now because of the structure of my api, I want articleCommentCount to be labelled comment_count (For json output sake only). So I modified my find() in the controller and specified something like;
->select([
'comment_count'=>'articleCommentCount'])
As you can see the value of articleCommentCount is mirrored to comment_count like below
{
"announcements": [
{
"id": 2,
"title":"title",
"articleCommentCount": 16
"comment_count": "16" //Notice value was mirrored BUT is a JSON STRING
}
]
}
Question: How do I avoid this issue of getting a String instead of an int
CakePHP Version 3.2