Writing a two-way bridge API for this can be quite a tedious task. I am the lead developer of an open-source tool called toFHIR that handles both transformations—JSON to FHIR and FHIR to JSON (and it also supports various file types). Maybe it can help solve your problem.