Wip 6397

Fix various valgrind warnings around json parsing, due to passing a string that was not NULL terminated.