server: Split json object generation into separate source
Factor the json object generation out from the rest of the server-specific code and compile it in a separate source that doesn't see any server code. This will make it re-usable for other ways of reporting the json objects.