File: jsonp_to_json.py

package info (click to toggle)
python-jenkinsapi 0.3.14-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 420 kB
  • sloc: python: 4,241; makefile: 3
file content (17 lines) | stat: -rw-r--r-- 335 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""
Module for converting jsonp to json.
"""

from __future__ import print_function


def jsonp_to_json(jsonp):
    try:
        l_index = jsonp.index("(") + 1
        r_index = jsonp.rindex(")")
    except ValueError:
        print("Input is not in jsonp format.")
        return None

    res = jsonp[l_index:r_index]
    return res