Table sys_dictionary: field types and their JSON Schema values

jeff00seattle
Kilo Guru

Greetings

 

I am working on generating a JSON Schema for specific tables and need assistance with particular fields:

  1. float
  2. decimal
  3. currency

How are field values presented if declared for each of these field types?

 

I am guessing for generating  JSON Schema are, each of these are all strings with numeric values, true?

 

currency: '12.3456'
decimal: '12.34'
float: '1.2345678'

 

 

Thank you

 

Reference

Field Types

 

1 REPLY 1

Tushar
Kilo Sage
Kilo Sage

Hi @jeff00seattle 

 

I think for generating a JSON Schema for specific fields like float, decimal, and currency, you're on the right track.

 

In JSON Schema, numeric values with decimal points are typically represented using the "number" type.

 

Although, JSON Schema itself doesn't inherently differentiate between float, decimal, or currency types. Instead, you can achieve the desired behavior using the "number" type along with additional constraints or custom formats.

 

Here's how you might represent these values:

  1. Floats are usually represented using the "number" type. You can use constraints like "minimum," "maximum," and "multipleOf" to define the acceptable range and precision of the floating-point value.

     
    { "type": "number", "minimum": 0, "maximum": 10, "multipleOf": 0.1 }
  2. JSON Schema doesn't have a separate "decimal" type, but you can use the "number" type with constraints to achieve decimal-like behavior.

     
    { "type": "number", "minimum": 0, "maximum": 100, "multipleOf": 0.01 }
  3. To represent currency values, you can use the "string" type along with a custom format. However, JSON Schema doesn't inherently interpret formats; it's mainly for documentation and validation purposes. For currency, you can define a regular expression pattern that includes the currency symbol.

     
    { "type": "string", "pattern": "^[0-9]+(\\.[0-9]{1,2})?\\sUSD$" }
     
     
     

    Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

    Regards,
    Tushar