Thanks to visit codestin.com
Credit goes to github.com

Skip to content

This (Directus) extension organizes JSON data by grouping fields based on common prefixes, making structured data retrieval easier for complex datasets.

Notifications You must be signed in to change notification settings

adrianjanocko/json-categorize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub

Overview

The Categorize JSON Extension provides a convenient way to organize JSON data by grouping fields based on their prefixes. This is particularly useful for applications that need to structure data sections dynamically, making the JSON response more readable and easier to work with.

For example, fields such as navbar_blog, navbar_forum, and footer_privacy_policy are automatically grouped under sections like navbar and footer, resulting in a more structured JSON output.

Special cases

  • Ignored fields: Field languages_code and fields that ends with _id are not categorized.
  • No subfield fields: For fields without a specific subfield (e.g., source and source_type), the category is determined by the prefix, and any standalone field (like source) without an underscore is categorized under a value.

Example of JSON categorization

Usage

After installation, this middleware will automatically organize JSON data for specified item routes in Directus.

To retrieve and categorize a specific item by its ID, use the following route:

GET /items/:collection/:id

If you use all in place of the :id parameter, the middleware will retrieve and categorize all items in the specified collection, returning a list of categorized objects:

GET /items/:collection/all

About

This (Directus) extension organizes JSON data by grouping fields based on common prefixes, making structured data retrieval easier for complex datasets.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •