Manual backport: Fix #367022, reported by amccann, patch by gapple: Use drupal_json to prevent issues with devel.