JSONDecodeError: ('unexpected or extra text', u'/')

New day new error, this time something with JSON decoding in a plugin that does not use JSON at all:

2013-12-12 18:45:56,678 (3938) :  CRITICAL (core:561) - Exception matching route for path "/video/iptvlite/listitems" (most recent call last):
  File "C:\Users\mdenisov\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\components\runtime.py", line 484, in match_route
    arg_value = self._core.data.json.from_string(arg_value)
  File "C:\Users\mdenisov\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\components\data.py", line 187, in from_string
    return demjson.decode(jsonstring, encoding)
  File "C:\Users\mdenisov\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Platforms\Shared\Libraries\demjson.py", line 2135, in decode
    obj = j.decode( unitxt )
  File "C:\Users\mdenisov\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Platforms\Shared\Libraries\demjson.py", line 1713, in decode
    raise JSONDecodeError('unexpected or extra text',txt[i:])
JSONDecodeError: ('unexpected or extra text', u'/')

I tried looking ad mentioned demjson.py file at lines 1702-1714 and it looks like problem is with some JSON structure with incorrect characters in it, maybe Cyrillic or something, but I don't know where to look for the said structure.

My best guess is that you're passing an argument or parameter to the ListItems function which is confusing the de-serializer. Looking at your code, it looks like you're passing a list which is made up of dicts. I suspect that the combination of data types is causing the problem. If you can rework your code so that you're passing a dict of dicts, that would probably work. Then you should hopefully be able to handle the necessary sorting/manipulation within the ListItems function.

On line 67 I am defining (or something) list object to work, if I change it to dict, how would it look then?

@route(PREFIX + '/listitems', items_list = dict)

like this?

On line 67 I am defining (or something) list object to work, if I change it to dict, how would it look then?

@route(PREFIX + '/listitems', items_list = dict)

like this?

Yes but, just changing the definition won't likely work unless you change the way you handle the data as well. One way to handle it would be to build a dict of dicts (rather than a list of dicts), then pass the complete dict to the ListItems() function which would then handle all the manipulation and build necessary menu directories. You'll need to decide which way to handle the data (that doesn't involve passing a list of dicts) that works best for your needs.

Thank You, looks like you're right, now just need the time to rewrite my code.

Strange however, I can not reproduce this error on my system :)

That is strange. Would the user reporting the issue be accessing different content? Perhaps it’s not the compound data-type that causing the problem but some strange character(s) in the data that the user has versus what you are accessing. Perhaps adding some Log() statements and getting fresh logs from the user will reveal something.

I made variable from local to global and now it doesn't give any errors, and I still can sort the list opposite to dictionary, thank You for the help.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.