JSON parse error


#1

Hey I am having trouble when retrieving a big JSON using the API the Live.GetLastVisitDetails method…i am using a perl function JSON->decode() and the error which I receive is ‘unexpected end of string while parsing JSON string, at character offset’. The thing is this doesn’t work only for several days which have quite a large amount of data…for the majority it works fine.

Thank you


(Matthieu Aubry) #2

Output the JSON when there is an error, i suspect the end of the string is missing?


#3

when i run the api in the browser mozilla gives me ‘There was an error parsing the JSON document. The document may not be well-formed.’ and the end o the json string is something like this :

{“idSite”:“1”,“idVisit”:“10523693”,“visitIp”:“196.211.161.245”,“visitorId”:“0000000000000000”,“visitorType”:“new”,“visitorTypeIcon”:null,“visitConverted”:“0”,“visitConvertedIcon”:null,“visitEcommerceStatus”:“none”,“visitEcommerceStatusIcon”:null,“actions”:“0”,“actionDetails”:[{“type”:“action”,“url”:“http://businessmonitor.com/request.pl?view=publicationsearch&file=SSZA19_20100701.pdf",“pageTitle”:null,“pageIdAction”:“11495793”,“pageId”:“12474857”,“serverTimePretty”:"Thu 6 May 14:03:26”,“icon”:null}],“customVariables”:{“2”:{“customVariableName2”:“No”,“customVariableValue2”:“72567”},“4”:{“customVariableName4”:“CC”,“customVariableValue4”:"|||"}},“goalConversions”:0,“siteCurrency”:“USD”,“siteCurrencySymbol”:"$",“serverDate”:“2010-05-06”,“visitLocalTime”:“00:00:00”,“firstActionTimestamp”:1273154606,“lastActionTimestamp”:1273154606,“lastActionDateTime”:“2010-05-06 14:03:26”,“visitDuration”:“0”,“visitDurationPretty”:“0s”,“visitCount”:“0”,“daysSinceLastVisit”:“0”,“daysSinceFirstVisit”:“0”,“daysSinceLastEcommerceOrder”:“0”,“country”:“Unknown”,“countryFlag”:“plugins/UserCountry/flags/xx.png”,“continent”:“Unknown”,“provider”:“Unknown”,“providerUrl”:“General - Analytics Platform - Matomo Entry”,“referrerName”:"",“referrerKeyword”:"",“referrerKeywordPosition”:null,“referrerUrl”:"",“referrerSearchEngineUrl”:null,“referrerSearchEngineIcon”:null,“operatingSystem”:"",“operatingSystemShortName”:"",“operatingSystemIcon”:“plugins/UserSettings/images/os/UNK.gif”,“browserFamily”:“unknown”,“browserFamilyDescription”:“Unknown”,“browserName”:";",“browserIcon”:“plugins/UserSettings/images/browsers/UNK.gif”,“screenType”:“mobile”,“resolution”:"",“screenTypeIcon”:“plugins/UserSettings/images/screens/mobile.gif”,“plugins”:"",“pluginsIcons”:null,“serverTimestamp”:1273154606,“serverTimePretty”:“14:03:26”,“serverDatePretty”:“Thu 6 May”,“serverDatePrettyFirstAction”:“Thu 6 May”,“serverTimePrettyFirstAction”:“14:03:26”},{“idSite”:“1”,“idVisit”:“10523531”,“visitIp”:“164.144.123.1”,“visitorId”:“0000000000000000”,“visitorType”:“new”,“visitorTypeIcon”:null,“visitConverted”:“0”,“visitConvertedIcon”:null,“visitEcommerceStatus”:“none”,“visitEcommerceStatusIcon”:null,“actions”:“0”,“actionDetails”:[{“type”:“action”,“url”:“http://businessmonitor.com/request.pl?view=articleviewer&article=346498&iso=+E,GR&storytype=9,14,192,368",“pageTitle”:null,“pageIdAction”:“11493648”,“pageId”:“12472674”,“serverTimePretty”:"Thu 6 May 14:03:14”,“icon”:null}],“customVariables”:{“2”:{“customVariableName2”:“No”,“customVariableValue2”:“70895”},“4”:{“customVariableName4”:“CC”,“customVariableValue4”:"|||"}},“goalConversions”:0,“siteCurrency”:“USD”,“siteCurrencySymbol”:"$",“serverDate”:“2010-05-06”,“visitLocalTime”:“00:00:00”,“firstActionTimestamp”:1273154594,“lastActionTimestamp”:1273154594,“lastActionDateTime”:"

So I suspect is as you said…the end of the json is truncated…but i can’t explain why it is doing that.