This will depend on the programming language you are using, but any modern programming language should have easy tools to convert a JSON object to a string, and then convert a string to its hex representation. If you state the language you are using we can add some more specific pointers here.