Tiny Tiny RSS: Community

getCategories returns mixed int/string for int values

tt-rss version: v20.06-697418f86

When making queries to the api for getCategories I get results like this:

{"seq":0,"status":0,"content":[{"id":"7","title":"electronics","unread":"3600","order_id":0},{"id":"8","title":"Podcasts","unread":"2040","order_id":0},{"id":"9","title":"tech","unread":"194","order_id":0},{"id":"11","title":"YouTube","unread":"1135","order_id":0},{"id":"39","title":"jobs","unread":"17","order_id":0},{"id":-2,"title":"Labels","unread":"0"},{"id":-1,"title":"Special","unread":0},{"id":0,"title":"Uncategorized","unread":"54"}]}

As you can see, id and unread come sometimes as ints, sometimes as strings.
This makes json parsing libraries like Go’s json to fail, or forces you to use an empty interface for something that’s clearly an int.

I’m not a PHP developer, but I think I have a patch that can work. I’ve seen that order_id is already casted to int, but not id nor unread. My (simple) patch does that.

I would like to open a PR for it. My username at Gogs is e1e0.

sure, you should have necessary privileges now.