- Qbs Manual
- PropertyList Service
- Qbs 1.20.1

# PropertyList Service

The `PropertyList` service allows you to read and write property list files in all formats supported by the Core Foundation API: XML, binary, JSON, and OpenStep (read-only).

This service is only available on Darwin platforms such as iOS, macOS, tvOS, and watchOS.

## Available operations

### Constructor

     PropertyList()

Allocates and returns a new PropertyList object.

### clear

     clear(): void

Voids the property list by deleting its internal object reference.

### isEmpty

     isEmpty(): boolean

Returns true if the property list has no internal object reference set, otherwise false.

### format

     format(): string

Returns the data format that the property list data was deserialized from. This property is set after calling `readFromString` or `readFromFile`. Possible return values include: `"binary1"`, `"json"`, `"openstep"`, and `"xml1"`. If the property list object is empty or the input format could not be determined, returns `undefined`.

### readFromFile

     readFromFile(filePath: string): void

Parses the file and stores the result in the property list. Throws an exception if an I/O error occurs or the input is in an invalid format.

### readFromObject

     readFromObject(obj: any): void

Sets the given object as the property list's internal object. `format()` will return `undefined` as this method does not deserialize a storage format.

### readFromString

     readFromString(input: string): void

Parses `input` and stores the result in the property list. This is most useful for initializing a property list object from the result of a `JSON.stringify` call. Throws an exception if the input is in an invalid format.

### toObject

     toObject(): any

Returns an object representing the property list.

### toJSON

     toJSON(style: string = "compact"): string

Returns a string representation of the property list in JSON format. Possible values for `style` include `"pretty"` and `"compact"`. The default is compact.

### toString

     toString(format: string): string

Returns a string representation of the property list in the specified format. Possible values for `format` include: `"json"` (compact), `"json-compact"`, `"json-pretty"`, and `"xml1"`. Currently, the OpenStep format is not supported. Throws an exception if the object cannot be written in the given format.

### toXMLString

     toXMLString(): string

Returns a string representation of the property list in XML format. This function is a synonym for `toString("xml1")`.

### writeToFile

     writeToFile(filePath: string, format: string): void

Writes the property list to the file in the given format. Possible values for `format` include: `"binary1"`, `"json"` (compact), `"json-compact"`, `"json-pretty"`, and `"xml1"`. Currently, the OpenStep format is not supported for writing. Throws an exception if an I/O error occurs or the object cannot be written in the given format.