code: public void writeNotifications(OutputStream out, Notification[] value) throws IOException {
          final NotificationRecord[] records;
          if (value != null) {
              records = new NotificationRecord[value.length];
              for (int i = 0; i < value.length; ++i) {
                  Notification n = value[i];
                  if (n != null) {
                      Object source = n.getSource();
                      NotificationRecord nr;
                      if (source instanceof ObjectName) {
                          nr = new NotificationRecord(n, (ObjectName) source);
                      } else {
                          nr = new NotificationRecord(n, (source != null) ? source.toString() : null);
                      }
                      records[i] = nr;
                  }
              }
          } else {
              records = null;
          }
          writeNotificationRecords(out, records);
      }
docs: Encode an array of Notification instance as JSON:
  
  @param out The stream to write JSON to
  @param value The Notification array to encode. Value can be null,
  but its items can't be null.
  The "source" of the items must be an instance of ObjectName.
  @throws IOException If an I/O error occurs
  @see #readNotifications(InputStream)