Do While CheckMoreJSONdataExists()
Dim JSONdata As String = GetNextJSONdata()
'sample test data
Dim JSONdata As String = "The New date is: g_date and it is a g_dayofweek"
Log("This: [" & JSONdata & "]")
If JSONdata.Contains("g_username") Then JSONdata = JSONdata.Replace("g_username", GetCurrentUserName())
If JSONdata.Contains("g_password") Then JSONdata = JSONdata.Replace("g_password", GetCurrentPassword())
If JSONdata.Contains("g_date") Then JSONdata = JSONdata.Replace("g_date", GetDateInLocalFormat())
If JSONdata.Contains("g_time") Then JSONdata = JSONdata.Replace("g_time", GetTimeInLocalFormat())
If JSONdata.Contains("g_dayofweek") Then JSONdata = JSONdata.Replace("g_dayofweek", GetDayOfWeek())
'or if you're not worried about efficiency and/or the substitution variables are already set then:
JSONdata = JSONdata.Replace("g_username", g_username)
JSONdata = JSONdata.Replace("g_password", g_password)
JSONdata = JSONdata.Replace("g_date", g_date)
JSONdata = JSONdata.Replace("g_time", g_time)
JSONdata = JSONdata.Replace("g_dayofweek", g_day_of_week) 'variable name doesn't have to match JSON name
JSONdata = JSONdata.Replace("$moonphase$", g_phase_of_moon) 'variable name can even be entirely different
Log("Becomes this: [" & JSONdata & "]")
Loop