Currently writing a JSON Importer and creating some POJOs based on the data. I also have a requirement to write an JSON Exporter which take the information in the POJOs and exports a JSON doc.To me I would like to reuse the the same code if possible. Does such a thing exist where you can reverse the function/method? i.e I could (depending on what I pass it) process it in the correct order and output the desired result, using the same code?Thanks  
Reversible Functions
design;design patterns;json
Yes, this is definitely possible.Invertible syntax descriptions: Unifying parsing and pretty printing by Tillmann Rendel and Klaus Ostermann is one fairly well-known approach for parsing/unparsing (which is kind of what you are doing) based on partial isomorphisms.The paper also points to other approaches based on Arrows (Polytypic compact printing and parsing by Patrik Jansson and Johan Jeuring), BiArrows (There and back again: arrows for invertible programming by Artem Alimarine, Sjaak Smetsers, Arjen van Weelden, Marko van Eekelen, and Rinus Plasmeijer, note that this is about invertible programming in general, not just parsing/unparsing or serialization/deserialization), and An injective language for reversible computation by Shin-Cheng Mu, Zhenjiang Hu, and Masato Takeichi, a full calculus for reversible programming in general.