json icon indicating copy to clipboard operation
json copied to clipboard

How to use both, pure and ext variant

Open mrckzgl opened this issue 2 years ago • 0 comments

Hi,

(until fix for https://github.com/flori/json/issues/515 gets released,) we want to use the pure variant to pretty generate some of our json (where it is important to have correct formatting), however for everything else the ext variant is preferred, as it is faster. Two problems arise with this:

  1. I haven't figured out in the docs how to explicitly use a specific variant while both are loaded. There is only one global object JSON which exposes the pretty_generate function. JSON::Ext or JSON::Pure do not. So how to explicitly call json pure pretty_generate?
  2. Whatever order I do the imports: require "json/ext" / require "json/pure", in both cases JSON::Generator resolves to JSON::Pure::Generator. How to load both variants and let JSON::Ext::Generator be the default?

mrckzgl avatar Mar 16 '23 10:03 mrckzgl