(function ($) {
  Drupal.behaviors.castorcito = {
    attach: function (context, settings) {
      let json = $('.castorcito-json-view .json-field', context).parent().find('pre code').text();

      if (json !== '') {
        $('.castorcito-json-view .json-field', context).parent().JSONView(json);
      }
    }
  };

})(jQuery);
