Search notes:

VBA: module JSON

The VBA module JSON is intended to store a few JSON related function.s
'
'      V.1
'
option explicit

function json_val(val as variant) as string ' {

   select case varType(val) ' {
      case vbInteger, vbLong, vbSingle, vbDouble
           json_val = val

      case vbString
           json_val = """" & replace(val, """", "\""") & """"

      case vbDate
           json_val = """" & dt_iso_8601(val) & """" ' format(val, "yyyy-mm-dd""T""HH:MM:SS")

      case vbBoolean
           json_val = lcase(val)

      case vbEmpty
           json_val = "null"

      case else
           msgBox "json_val: Unrecognized datatype " & typeName(val) & ", " & varType(val)

      end select ' }

end function ' }

function json_key(name as variant) as string ' {
 '
 ' Create something that can be used as a JSON-Key, for example:
 '   "keyValue":

   json_key = json_val(name) & ":"
end function ' }

function json_name_value(name as string, val as variant) ' {
    json_name_value = json_val(name) & ": " & json_val(val)
end function ' }
Github repository VBAModules, path: /Common/JSON.vb

See also

This module depends on dateTime.vb.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758186011, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/VBA/modules/Common/JSON(81): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78