Community

Comments

2 comments

  • Avatar
    Koen de Leijer

    Hi

    Take a look at this post, https://forum.ocrsdk.com/thread/how-to-use-api/
    I you're using the Cloud Wrapper you should be able to set the outputFormat to XML.

    Json is not an option: https://www.ocrsdk.com/documentation/specifications/export-formats/

    How far did you get? Post some of your code

    Best regards

    Koen de Leijer

    0
    Comment actions Permalink
  • Avatar
    JonsonSmith

    Not thus pretty, however this could get the work done, I think. you'd get a dictionary that then gets printed by the json parser in a very nice, pretty format.

    import json    
    
    def get_data(page_content):
        _dict = {}
        page_content_list = page_content.splitlines()
        for line in page_content_list:
            if ':' not in line:
                continue
            key, value = line.split(':')
            _dict[key.strip()] = value.strip()
        return _dict
    
    page_data = get_data(page_content)
    json_data = json.dumps(page_data, indent=4)
    print(json_data)

    or, rather than those last three lines, simply do this:

    print(json.dumps(get_data(page_content), indent=4))
    0
    Comment actions Permalink

Please sign in to leave a comment.