/// <summary>
        /// Create an Hardware mapping from a raw json string
        /// </summary>
        /// <param name="jsonHardwareData">the hardware json description string</param>
        public static HardwareData LoadData(string jsonData)
        {
            HardwareData d = new HardwareData();

            JToken data = JToken.Parse(jsonData);
            // Parses push buttons' data:
            JObject pushButtonObj = (JObject)data.SelectToken("PushButton");

            if (pushButtonObj != null)
            {
                string type       = (string)pushButtonObj.SelectToken("type");
                string identifier = (string)pushButtonObj.SelectToken("identifier");
                if (identifier != null)
                {
                    PushButton.UpdateIdentifier(identifier);
                }
                // Check what type of pushbutton the hardware has:
                if (type == "list")
                {
                    int btnCount = (int)pushButtonObj.SelectToken("size");
                    for (int i = 0; i < btnCount; i++)
                    {
                        d.PushButtons.Add(new PushButton(i));
                    }
                }
                else if (type == "matrix")
                {
                    d.HasInitializedAsMatrix = true;
                    d.MatrixLayout           = (string)pushButtonObj.SelectToken("layout");
                    int count = (int)pushButtonObj.SelectToken("size");
                    for (int i = 0; i < count; i++)
                    {
                        d.PushButtons.Add(new PushButton(i));
                    }
                }
                else
                {
                    //log unknown/invalid type
                }
            }

            // Parses rotary encoders' data:
            JArray rotEnc = (JArray)data.SelectToken("RotaryEncoder");

            if (rotEnc != null)
            {
                for (int i = 0; i < rotEnc.Count; i++)
                {
                    int  id        = (int)rotEnc[i].SelectToken("id");
                    bool hasButton = (bool)rotEnc[i].SelectToken("hasButton");
                    d.RotaryEncoders.Add(new RotaryEncoder(id, hasButton));
                }
            }

            // Parses knobs' data
            JObject knobsObj = (JObject)data.SelectToken("Knobs");

            if (knobsObj != null)
            {
                int knobsCount = (int)knobsObj.SelectToken("size");
                for (int i = 0; i < knobsCount; i++)
                {
                    d.Knobs.Add(new Knob(i));
                }
            }

            return(d);
        }