Data Types

Learn about usage and manipulation of data types in TonCut Engine.

Time

The time unit can take the following values:

  • "s" for seconds,
  • "m" for minutes,
  • "h" for hours and
  • "d" for days.

It can be changed by setting the time property in the defaultUnits JSON object.

The default time unit is used only if the value does not specify the unit.

So, if the default unit is set to minutes "m", and you specify { "value": 5.5 }, then it will be treated as 5.5 minutes.

However, you can still force the unit in the value by setting it as a string: { "value": "5.5s" }. In this case, the value will be treated as 5.5 seconds, regardless of the default time unit.

The default time unit is a second "s".

Changing default time unit

{
    "defaultUnits": {
        "time": "m"
    }
}

Percent

It doesn’t matter if you specify a percentage value as 50 or "50%" - it will always be treated as 50%.

To be consistent, we have the percent property in the defaultUnits JSON object, but it should always be set to "%".

The percent unit can take only one value: "%", which is also the default.

Setting percent property to "%"

{
    "defaultUnits": {
        "percent": "%"
    }
}

Length

The length unit can take the following values:

  • "mm" for millimeters,
  • "cm" for centimeters and
  • "in" for inches.

Default length unit can be changed by setting the length property in the defaultUnits JSON object.

The default length unit is a millimeter "mm".

Setting length property to "cm"

{
    "defaultUnits": {
        "length": "cm"
    }
}

Field

The field unit can take the following values:

  • "sqmm" for square millimeters,
  • "sqcm" for square centimeters,
  • "sqm" for square meters,
  • "sqin" for square inches and
  • "sqft" for square feet.

It can be changed by setting the field property in the defaultUnits JSON object.

The default field unit is used only if the value does not specify the unit.

So, if the default unit is set to square meters "sqm", and you specify { "value": 250 }, then it will be treated as 250 square meters (250m2).

However, you can still force the unit in the value by setting it as a string: { "value": "250sqmm" }. In this case, the value will be treated as 250 square millimeters (250mm2), regardless of the default field unit.

The default field unit is a square millimeter "sqmm".

Setting field property to "sqm"

{
    "defaultUnits": {
        "field": "sqm"
    }
}

Angle

The angle unit can take the following values:

  • "rad" for radians,
  • "deg" for degrees.

Default angle unit can be changed by setting the angle property in the defaultUnits JSON object.

The default angle unit is used only if the value does not specify the unit.

So, if the default unit is set to degrees "deg", and you specify { "value": 0.5 }, then it will be treated as 0.5 degrees (0.5°).

However, you can still force the unit in the value by setting it as a string: { "value": "0.5rad" }. In this case, the value will be treated as 0.5 radians, regardless of the default angle unit.

The default angle unit is radian "rad".

Setting angle property to "deg"

{
    "defaultUnits": {
        "angle": "deg"
    }
}

Weight

The weight unit can take the following values:

  • "mg" for milligrams,
  • "g" for grams,
  • "kg" for kilograms,
  • "t" for metric tons (1000 kg),
  • "oz" for ounces (avoirdupois),
  • "lb" for pounds,
  • "sht" for short tons (US ton, 2000 lb),
  • "st" for stones (14 lb, UK),
  • "toz" for troy ounces (31.1035 g, precious metals).

The default weight unit can be changed by setting the weight property in the defaultUnits JSON object.

The default weight unit is used only if the value does not specify the unit.

So, if the default unit is set to kilograms "kg", and you specify { "value": 250 }, then it will be treated as 250 kilograms.

However, you can still force the unit in the value by setting it as a string: { "value": "250lb" }. In this case, the value will be treated as 250 pounds, regardless of the default weight unit.

The default weight unit is kilogram "kg".

Setting weight property to "lb"

{
    "defaultUnits": {
        "weight": "lb"
    }
}

Price

The price type stores a monetary amount. The optimizer assumes that all price values are expressed in the same currency and performs no currency conversion. Enter every cost and revenue figure using one consistent currency to ensure correct calculations.


Enum

The enum type is a value type that defines a set of named constants. In this documentation, enum types are specified using the format: enum(value1, value2, value3)

Only one of the specified values can be used, for example:

  { "property": "value2" }

In our JSON, enum types are represented as strings.


Set

The set type is similar to the enum type, with the exception that it allows for the assignment of multiple values. Like the enum type, it defines a set of named constants. In this documentation, set types are specified using the format: set(value1, value2, value3)

Any combination of the specified values can be used, for example:

{ "property": ["value1", "value2"] }

As shown in the example above, all values are contained within a JSON array.

In our JSON, set types are represented as arrays containing strings.


Date

The date type represents date and time.

JSON format does not support date format so we are using ISO 8601 format.