JavaScript
Article

Example Colors JSON File

By Sam Deering

This is an example of a Colors JSON file which you might see used to store configuration settings to setup your system. It might also be used to contain color information which can be easily shared across components using the simple JSON format.

Also: See more JSON examples.

{
    "colorsArray":[{
            "colorName":"red",
            "hexValue":"#f00"
        },
        {
            "colorName":"green",
            "hexValue":"#0f0"
        },
        {
            "colorName":"blue",
            "hexValue":"#00f"
        },
        {
            "colorName":"cyan",
            "hexValue":"#0ff"
        },
        {
            "colorName":"magenta",
            "hexValue":"#f0f"
        },
        {
            "colorName":"yellow",
            "hexValue":"#ff0"
        },
        {
            "colorName":"black",
            "hexValue":"#000"
        }
    ]
}

Or simply:

{
    "colorsArray":[{
            "red":"#f00",
            "green":"#0f0",
            "blue":"#00f",
            "cyan":"#0ff",
            "magenta":"#f0f",
            "yellow":"#ff0",
            "black":"#000"
        }
    ]
}

Or even simply:

{
    "red":"#f00",
    "green":"#0f0",
    "blue":"#00f",
    "cyan":"#0ff",
    "magenta":"#f0f",
    "yellow":"#ff0",
    "black":"#000"
}
Sam Deering
Meet the author
Sam Deering is a Front-end Web Developer who specialises in JavaScript & jQuery. Sam is driven and passionate about sharing his knowledge to educate others.
Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!