CodeMirror does not do formatting (though maybe you just mean indentation).
There is a JSON mode (mime application/json) but that does not highlight JSON markup inside a string. If you have some situation where you are embedding JSON in strings, you could try writing an overlay mode that wraps the JSON mode to get it highlighted.