Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-13407

history.get doesn't output value for numbers in JSON right

XMLWordPrintable

    • Icon: Problem report Problem report
    • Resolution: Won't fix
    • Icon: Trivial Trivial
    • None
    • 3.4.6
    • API (A)
    • RHEL 7 with Elasticsearch as history back-end

      I'm writing a google go package for abstracting the pure zabbix
      APIs and exposing nice-to-use native data structures. The
      encoding/json package included with the languge, take care
      of converting a JSON to a native and ready to use structure
      or array of structures.

      It appear that the history.get API, for numeric values, always
      return a JSON string in the value field. While it's possible to
      convert the value without problems, it can be problematic for
      softwares that rely on the proper JSON notation for number types
      for infering the proper type for a variable, thus complicating
      the implementation of programs that use the API in strongly
      statically typed languages.

      Steps to reproduce:
      Make a simple call to the history.get API for a numeric type (integers or floats) and check the returned JSON format.

      Result:

      {
        "jsonrpc": "2.0",
        "result": [
          {
            "itemid": 23314,
            *"value": "0"*,
            "clock": 1516284994,
            "ns": 283022645,
            "ttl": 604800
          }
        ],
        "id": 1
      }
      

      Expected:

      {
        "jsonrpc": "2.0",
        "result": [
          {
            "itemid": 23314,
            *"value": 0*,
            "clock": 1516284994,
            "ns": 283022645,
            "ttl": 604800
          }
        ],
        "id": 1
      }
      

            Unassigned Unassigned
            abiscuola Andrea Biscuola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: