Dev json xff v0.4

New version based on previous PR #1111.
Ok, I'm not also really 100% on those last 3 lines, will tinker something better.