Fixed XML to JSON conversion.

Also fixed recursion problem with opt() methods.