implementation of jsonpatch apply