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
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

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