suppose the value of "/tmp" is stored in the association "mymodule.dynamicrelation", introduce an string type attribute named "dynamicrelation_jsonkey", and give it just before serialization the value "/tmp" (or whathever you need).
That should do the trick, "_jsonkey" attributes are used to serialize strangely named attributes, and take precedence over the attribute name itself.
See: https://github.com/mendix/restservices#serializing-complex-attribute-names