Tealium.TealiumTagger.GetJson C# (CSharp) Method

GetJson() private method

private GetJson ( string>.Dictionary variablesToSend ) : string
variablesToSend string>.Dictionary
return string
        private string GetJson(Dictionary<string, string> variablesToSend)
        {
            if (variablesToSend == null || variablesToSend.Count == 0)
                return "{ }"; //equivalent to string.Empty for our purposes

            string v = string.Empty;
            foreach (var item in variablesToSend)
            {
                if (item.Key != null && item.Value != null)
                {
                    if (v != string.Empty)
                        v += ",";
                    v += string.Format("\"{0}\": \"{1}\"", item.Key.HtmlEncode(), item.Value.HtmlEncode());
                }
            }
            return "{ " + v + " }";
        }