- Issue created by @jrb
- Status changed to Needs review
about 2 years ago 8:03pm 13 March 2023 - πΊπΈUnited States jrb Raleigh-Durham Area, NC, USA
Attached patch formats the JSON in the config using JSON_PRETTY_PRINT.
Note that, before the patch, the TB Mega Menu code called
Json::encode($menuConfig)
which made this call:public static function encode($variable) { // Encode <, >, ', &, and ". return json_encode($variable, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT); }
The patched code now just calls
json_encode()
directly with those same options plus JSON_PRETTY_PRINT. - πΊπΈUnited States jrb Raleigh-Durham Area, NC, USA
Related:
There is a core issue suggesting that optional parameters should be added to
Json::encode($menuConfig)
to allow passing of flags:π Json::encode() and Json::decode() limit what we can do with JSON Needs work
If that patch does land, this code could be updated. Until then, this patch uses the suggested workaround of just calling
json_encode()
directly so we can pass our own flags. - Status changed to RTBC
almost 2 years ago 3:34pm 9 June 2023 - πΊπΈUnited States themodularlab
@jrb,
I love this. Thank you.
I just tested your patch. Everything works as expected on config import and export. The JSON config is now readable.
I'll commit this to the 2.x branch and include it in a future release. Thanks again. -
themodularlab β
committed 75e81866 on 2.x authored by
jrb β
Issue #3347708 by jrb: Use JSON_PRETTY_PRINT to encode JSON so config...
-
themodularlab β
committed 75e81866 on 2.x authored by
jrb β
- Status changed to Fixed
almost 2 years ago 3:36pm 9 June 2023 - πΊπΈUnited States themodularlab
For Drupal 9: Use https://www.drupal.org/project/tb_megamenu/releases/2.0.0-alpha6 β
For Drupal 10: use https://www.drupal.org/project/tb_megamenu/releases/3.0.0-alpha1 β Automatically closed - issue fixed for 2 weeks with no activity.