add null pointer check to inline object handling, move writer object to parameter to allow adding rapidjson-aware callers to inject objects into their own documents