votes up 3

No start of json char found

Package:
ansible
github stars 49704
Exception Class:
ValueError

Raise code

        if line.startswith(u'{'):
            endchar = u'}'
            break
        elif not objects_only and line.startswith(u'['):
            endchar = u']'
            break
    else:
        raise ValueError('No start of json char found')

    # Filter trailing junk
    lines = lines[start:]

    for reverse_end_offset, line in enumerate(reversed(lines)):
        if line.strip().endswith(endchar):
            break
🙏 Scream for help to Ukraine
Today, 14th August 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too! We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.

Ways to fix

votes up 1 votes down

Summary: Make sure you use the symbol "{" at the beginning of the line json:

Code to reproduce (WRONG):

from ansible.module_utils.json_utils import _filter_non_json_lines
json_text = u'"key":"value"}'
filtered, warnings = _filter_non_json_lines(jsons)
print('filtered', filtered)
print('warnings', warnings)

Working version (Fixed):

from ansible.module_utils.json_utils import _filter_non_json_lines
json_text = u'{"key":"value"}' # <--- HERE IS A FIX WE ADDED "{"
filtered, warnings = _filter_non_json_lines(jsons)
print('filtered', filtered)
print('warnings', warnings)
Jul 09, 2021 nurzod answer
nurzod 62

Add a possible fix

Please authorize to post fix