Function serializeAutoClosingPairs