Example #1
0
        public static string ToJSON(this BCCuePoint cuePoint)
        {
            Builder jsonCP = new Builder(",", "{", "}");

            //name
            if (!string.IsNullOrEmpty(cuePoint.name))
            {
                jsonCP.AppendField("name", cuePoint.name);
            }

            //time
            if (!string.IsNullOrEmpty(cuePoint.time.ToString()))
            {
                jsonCP.AppendObject("time", cuePoint.time);
            }

            //forceStop
            jsonCP.AppendField("forceStop", cuePoint.forceStop.ToString().ToLower());

            //type
            if (!string.IsNullOrEmpty(cuePoint.type.ToString()))
            {
                jsonCP.AppendObject("type", (int)Enum.Parse(typeof(CuePointType), cuePoint.type.ToString()));
            }

            //metadata
            if (!string.IsNullOrEmpty(cuePoint.metadata))
            {
                jsonCP.AppendField("metadata", cuePoint.metadata);
            }

            return(jsonCP.ToString());
        }
        public static string ToJSON(this BCCuePoint cuePoint)
        {
            StringBuilder jsonCP = new StringBuilder();

            jsonCP.Append("{");

            if (!string.IsNullOrEmpty(cuePoint.name))
            {
                //name
                jsonCP.Append("\"name\": \"" + cuePoint.name + "\",");
            }

            //time
            if (!string.IsNullOrEmpty(cuePoint.time.ToString()))
            {
                jsonCP.Append("\"time\": " + cuePoint.time);
            }

            //forceStop
            jsonCP.Append(",\"forceStop\": \"" + cuePoint.forceStop.ToString().ToLower() + "\"");

            //type
            if (!string.IsNullOrEmpty(cuePoint.type.ToString()))
            {
                jsonCP.Append(",\"type\": " + (int)Enum.Parse(typeof(CuePointType), cuePoint.type.ToString()));
            }

            //metadata
            if (!string.IsNullOrEmpty(cuePoint.metadata))
            {
                jsonCP.Append(",\"metadata\": \"" + cuePoint.metadata + "\"");
            }

            jsonCP.Append("}");

            return(jsonCP.ToString());
        }