The HealthVault comma-separated data format is used to store data in a space-efficient format in the other-data section of data types.

The actual data types provide a layer of abstraction on top of the comma-separated types, and it is recommended that data is accessed through those abstractions rather than using the underlying support types. However, it can be useful to understand how the support types work.

The underlying comma-separated format follows the “C-style” rules for character escaping, where a “\” can be placed in front of any character to escape it.

In addition, the format supports the concept of an “escape”, which is a “name=value” pair that is placed in the comma-separated list instead of a value. The meaning of escapes is defined by a particular data type.

List entry definition

Each item in the comma-separated list is represented as an instance of a class derived from OtherItemDataCsvItem. There are 3 primitive item types derived from this base class:

  • OtherItemDataCsvString is a string value.
  • OtherItemDataCsvDouble is a double value.
  • OtherItemDataCsvEscape is an escape.

class OtherItemDataCsv

This class handles converting between the instance-based model that is used by the data type class and the underlying string representation.

To store data to the string representation, the data type calls SetOtherData() and passes in a collection of OtherItemDataCsvItem instances. This method will take the individual instances in the collection, call the ToString() method on them, and then place the resulting string values into the comma-separated format, applying appropriate character escaping.

To convert data from the string representation to a collection, the data type calls GetAsString(). This returns a collection of OtherItemDataCsvItem that contains either string items or escape items. If the data type knows that the data contains only double values and escapes, it can instead call GetAsDouble(), and all string values will be converted to doubles as a convenience.

Note that there is no type information stored in the raw string format, so all items are inherently strings when they are retrieved, and any interpretation to a different type is done based on information that the data type has, not information stored with the data.