Dev json xff v0.4

New version based on previous PR #1111.
I'm not too happy about this strlen usage. It's not a string we're working with. Even though it does appear to be safe due to the added 0 earlier, I would like to see a different solution here.