Reference · Map, locator and quiz elements
readMapDatafunction
Parse finite choropleth figures; invalid JSON and nested or non-numeric values are rejected.
Import it
import { readMapData } from "@johnmorrisdotca/chizu/element";
Also exported from: @johnmorrisdotca/chizu/element/define
Definition
function readMapData(text: string | null): Record<string, number> | null
Parameters
| Name | Type | Description |
|---|---|---|
text | string | null | The JSON text to read; null means no data. |
Returns
Record<string, number> | null
Finite values keyed by place code, or null when no data was supplied.
Examples
import { readMapData } from "@johnmorrisdotca/chizu/element";
console.log(JSON.stringify(readMapData('{"JP":10}')), readMapData('{"JP":"bad"}'));
// {"JP":10} null{"JP":10} nullWhat it prints (run when this page was built)