[Tools] Create JSON reader
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3554727. -->
Reported by: [marcus_johansson](https://www.drupal.org/user/385947)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>You need to be able to read and extract structured data from JSON files. Since JSON is a native and well-supported format in PHP, this can be natively supported and can thus be part of the core packages.</p>
<p>In terms of naming, the tool could be either "Read JSON Data" or "Load JSON Data". Following the same logic as CSV, since it is a structured format, "Load JSON Data" would be the most consistent choice.</p>
<p>The inputs for this extractor should be:</p>
<p>* File Source (binary, required). The JSON file being loaded. How to load this is TBD. An actual serialized json blob should also be possible.<br>
* JSON Path (string, default null). The path within the JSON object to start extracting from. If null, extract from the root.<br>
* Message Format (enum, default json). The return format for the message, can also be yaml, mainly useful for AI or output standardization.</p>
<p>The output format in string format will be the JSON file as-is unless a different message format is specified.</p>
<p>If JSON Path is used, the root starts from the extracted data, not including the JSON path.</p>
<p>As for checkAccess, if the file loading happens before this tool, nothing should really need to be checked. If the file loading from uri, url, fid, etc. happens here, it has to be:</p>
<p>1. fid - check access to the file entity.<br>
2. uri - if it’s managed by Drupal, check access to the file entity, otherwise ensure the file is reachable.<br>
3. url - check that the file can be reached.<br>
4. data - no checks needed.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>* If the tool_utilities submodule does not exist yet, create the metadata for it.<br>
* Create the "Load JSON Data" tool according to the instructions above.<br>
* Implement support for an optional JavaScript-annotated extractor function that allows dynamic extraction and transformation of JSON data.<br>
* Write unit tests to ensure the output matches the expected input for both static extraction and JS-based extraction.<br>
* Add validation for safe execution of JavaScript extractor functions and fallback behavior when unavailable.<br>
* Use Drupals JSON serializer/unseriazlier </p>
issue