Run a jar file before insert or before update

hi guys,
i am need to run a jar file before insert or before update.
i want change documents before insert or update.
how do I do it?
thank you.

You can have a look at ingest feature may be?

Hard to say if it will work for you as I don't understand what you are exactly trying to solve.

i use msgpack for faster and smaller transfer. " http://msgpack.org/index.html "
documents sent in the form of hex by client,
and i need to unpack documents before insert or update.

Do you have any issue by using JSON?
Did you try CBOR?