mercredi 30 octobre 2019

Multiple JSON schemas (products) - how to load correct schema based on keywords?

Question

Where should search keywords and brand names go in a JSON schema (multiple files) in order to search multiple JSON schemas (100-1000s) and select the applicable one?

Background

Not new to programming, I'm relatively new to JSON.

I'm in process of creating a JSON Schema Builder and Form Generator from the schema in Angular - Work In Progress Stackblitz.

I plan to generate a form (from 1 x schema) for approx 100s (potentially 1000s) of products.

Against each product are search keywords and brand names and I plan to use these to search for a product schema (loads the schema hence the form).

Possible ideas:

  1. Keep one huge single JSON file (I want to avoid this)
  2. Keep a meta json schema with keywords in an annotation, load this and use this to select and load correct schema

search-schema.json

{
  "type": "object",
  "properties": {
      "plywood.json": {
          "description": "plywood ply" <---- keywords
      },
      "pens.json": { ...
  }
}
  1. Save schemas to a database and use database functionality to search for correct schema (is this avoidable/desirable/prefered?).

Aucun commentaire:

Enregistrer un commentaire