FromJSON
Converts the JSON object into the ApiColor object.
Syntax
expression.FromJSON(jsonObject);
expression - A variable that represents a ApiColor class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| jsonObject | Required | string | JSON representation of the color. |
Returns
ApiColor | null
Example
This example shows how to restore a shape fill color from JSON.
- Code
- Result
const worksheet = Api.GetActiveSheet();
const original = Api.RGB(93, 192, 232);
const json = JSON.parse(original.ToJSON());
const restored = original.FromJSON(json);
const fill = Api.CreateSolidFill(restored);
const stroke = Api.CreateStroke(36000, Api.CreateSolidFill(Api.RGB(0, 0, 0)));
worksheet.AddShape("rect", 120 * 36000, 70 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);
worksheet.GetRange("A12").SetValue("Original: " + original.GetHex() + " | Restored: " + restored.GetHex());