Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong JSON reply from API (SitesManager.getAllSites) #14168

Closed
benginoe opened this issue Mar 8, 2019 · 1 comment
Closed

Wrong JSON reply from API (SitesManager.getAllSites) #14168

benginoe opened this issue Mar 8, 2019 · 1 comment
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@benginoe
Copy link

benginoe commented Mar 8, 2019

Dear developers,

i have recently got an issue with handling the response of "/?module=API&method=SitesManager.getAllSites&format=JSON" i dont get a proper json reply.

[ { "idsite": "1", "name": "Test", "main_url": "http://abc.me", "ts_created": "2019-02-01 17:06:20", "ecommerce": "0", "sitesearch": "1", "sitesearch_keyword_parameters": "", "sitesearch_category_parameters": "", "timezone": "UTC", "currency": "USD", "exclude_unknown_urls": "0", "excluded_ips": "", "excluded_parameters": "", "excluded_user_agents": "", "group": "", "type": "website", "keep_url_fragment": "0", "creator_login": "anonymous", "timezone_name": "UTC", "currency_name": "US Dollar" }, { "idsite": "2", "name": "xzy.de", "main_url": "http://www.xzy.de", "ts_created": "2019-03-07 00:00:00", "ecommerce": "0", "sitesearch": "1", "sitesearch_keyword_parameters": "", "sitesearch_category_parameters": "", "timezone": "UTC-1", "currency": "USD", "exclude_unknown_urls": "0", "excluded_ips": "", "excluded_parameters": "", "excluded_user_agents": "", "group": "", "type": "website", "keep_url_fragment": "0", "creator_login": "XYZ", "timezone_name": "UTC-1", "currency_name": "US Dollar" }, { "idsite": "3", "name": "xyz.de", "main_url": "http://www.xyz.de", "ts_created": "2007-07-24 00:00:00", "ecommerce": "0", "sitesearch": "1", "sitesearch_keyword_parameters": "", "sitesearch_category_parameters": "", "timezone": "UTC-1", "currency": "USD", "exclude_unknown_urls": "0", "excluded_ips": "", "excluded_parameters": "", "excluded_user_agents": "", "group": "", "type": "website", "keep_url_fragment": "0", "creator_login": "XYZ", "timezone_name": "UTC-1", "currency_name": "US Dollar" }, { "idsite": "4", "name": "blabla", "main_url": "http://www.google.de", "ts_created": "2018-07-24 00:00:00", "ecommerce": "0", "sitesearch": "1", "sitesearch_keyword_parameters": "", "sitesearch_category_parameters": "", "timezone": "UTC-2", "currency": "USD", "exclude_unknown_urls": "0", "excluded_ips": "", "excluded_parameters": "", "excluded_user_agents": "", "group": "", "type": "website", "keep_url_fragment": "0", "creator_login": "XYZ", "timezone_name": "UTC-2", "currency_name": "US Dollar" } ]

should it not look more like this

["sites":{"idsite": "4"....

Matomo-Version: 3.8.1
MySQL-Version: 5.5.60-MariaDB
PHP-Version: 7.2.15

Thanks so far for your assistance and great work!

@Findus23
Copy link
Member

Findus23 commented Mar 8, 2019

I'm pretty sure the response is correct as it returns a list of objects.

This is valid JSON:

[
  {
    "key": 1,
    "anotherkey": 2
  },
  {
    "morekey": 3,
    "lastkey": 4
  }
]

Of course this is also valid JSON, but I don't see the advantage, it only seems to be more verbose:

{
  "sites": [
    {
      "key": 1,
      "anotherkey": 2
    },
    {
      "morekey": 3,
      "lastkey": 4
    }
  ]
}

Keep in mind that JSON doesn't even need to include objects/dicts, as this is also valid JSON:

"hello"

as is this:

1

@Findus23 Findus23 closed this as completed Mar 8, 2019
@Findus23 Findus23 added the answered For when a question was asked and we referred to forum or answered it. label Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

2 participants