1# @ohos.data.uniformDataStruct (Uniform Data Structs) 2 3As a part of the Unified Data Management Framework (UDMF), the **uniformDataStruct** module provides data structs corresponding to certain [UniformDataTypes](js-apis-data-uniformTypeDescriptor.md#uniformdatatype) for service scenarios of many-to-many data sharing across applications. It helps simplify data interaction and reduce the data type adaptation workload. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8 9## Modules to Import 10 11```js 12import { uniformDataStruct } from '@kit.ArkData'; 13``` 14 15## PlainText 16 17Represents data of the plain text type. 18 19**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 20 21| Name | Type | Read-Only| Optional| Description | 22| ----------- | ------ | ---- | ---- |-----------------------| 23| uniformDataType | 'general.plain-text'| Yes | No | Uniform data type, which has a fixed value of **general.plain-text**. For details, see [UniformDataType](js-apis-data-uniformTypeDescriptor.md#uniformdatatype). | 24| textContent | string | No | No | Plaintext content. | 25| abstract | string | No | Yes | Text abstract. It is an empty string by default.| 26| details | Record<string, string> | No | Yes| Object of the dictionary type used to describe the properties of the text content. Both the key and value of the object are of the string type. The following is a **details** object used to describe the properties of a file:<br>{<br>"title":"Title of the file",<br>"content":"Content of the file"<br>}<br> By default, it is an empty dictionary object.| 27 28**Example** 29 30```ts 31let plainTextDetails : Record<string, string> = { 32 'attr1': 'value1', 33 'attr2': 'value2', 34} 35let plainText : uniformDataStruct.PlainText = { 36 uniformDataType: 'general.plain-text', 37 textContent : 'This is plainText textContent example', 38 abstract : 'this is abstract', 39 details : plainTextDetails, 40} 41console.info('plainText.uniformDataType: ' + plainText.uniformDataType); 42if(plainText.details != undefined){ 43 let plainTextDetailsObj : Record<string, string> = plainText.details; 44 for(let kv of Object.entries(plainTextDetailsObj)) { 45 console.info('plainText.details.attr: ' + kv[0] + ', value:' + kv[1]); 46 } 47} 48``` 49 50## Hyperlink 51 52Represents data of the hyperlink type. 53 54**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 55 56| Name | Type | Read-Only| Optional| Description | 57| ----------- | ------ | ---- | ---- |--------------| 58| uniformDataType | 'general.hyperlink'| Yes | No | Uniform data type, which has a fixed value of **general.hyperlink**. For details, see [UniformDataType](js-apis-data-uniformTypeDescriptor.md#uniformdatatype).| 59| url | string | No | No | URL. | 60| description | string | No | Yes | Description of the linked content. This parameter is optional. By default, it is an empty string.| 61| details | Record<string, string> | No | Yes | Object of the dictionary type used to describe the properties of the hyperlink. Both the key and value of the object are of the string type. <br/>Example:<br>{<br>"title":"Title of the hyperlink",<br>"content":"Content"<br>}<br> By default, it is an empty dictionary object.| 62 63**Example** 64 65```ts 66let hyperlinkDetails : Record<string, string> = { 67 'attr1': 'value1', 68 'attr2': 'value2', 69} 70let hyperlink : uniformDataStruct.Hyperlink = { 71 uniformDataType:'general.hyperlink', 72 url : 'www.XXX.com', 73 description : 'This is the description of this hyperlink', 74 details : hyperlinkDetails, 75} 76console.info('hyperlink.uniformDataType: ' + hyperlink.uniformDataType); 77``` 78 79## HTML 80 81Represents data of the HTML type. 82 83**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 84 85| Name | Type | Read-Only| Optional| Description | 86| ------------ | ------ | ---- | ---- |-----------------------| 87| uniformDataType | 'general.html'| Yes | No | Uniform data type, which has a fixed value of **general.html**. For details, see [UniformDataType](js-apis-data-uniformTypeDescriptor.md#uniformdatatype).| 88| htmlContent | string | No | No | Content in HTML format. | 89| plainContent | string | No | Yes | Plaintext without HTML tags. This parameter is optional. By default, it is an empty string.| 90| details | Record<string, string> | No | Yes | Object of the dictionary type used to describe the properties of the HTML content. Both the key and value of the object are of the string type. <br/>Example:<br>{<br>"title":"Title of the HTML content",<br>"content":"Content"<br>}<br> By default, it is an empty dictionary object.| 91 92**Example** 93 94```ts 95let htmlObjDetails : Record<string, string> = { 96 'attr1': 'value1', 97 'attr2': 'value2', 98} 99let htmlObj : uniformDataStruct.HTML = { 100 uniformDataType :'general.html', 101 htmlContent: '<div><p>Title</p></div>', 102 plainContent : 'this is plainContent', 103 details : htmlObjDetails, 104} 105console.info('htmlObj.uniformDataType: ' + htmlObj.uniformDataType); 106``` 107 108## OpenHarmonyAppItem 109 110Represents data of the home screen icon type defined by the system. 111 112**System capability**: SystemCapability.DistributedDataManager.UDMF.Core 113 114| Name | Type | Read-Only| Optional| Description | 115| ----------- | ------ | ---- | ---- |-----------------| 116| uniformDataType | 'openharmony.app-item'| Yes | No | Uniform data type, which has a fixed value of **openharmony.app-item**. For details, see [UniformDataType](js-apis-data-uniformTypeDescriptor.md#uniformdatatype).| 117| appId | string | No | No | ID of the application, for which the icon is used. | 118| appName | string | No | No | Name of the application, for which the icon is used. | 119| appIconId | string | No | No | Image ID of the icon. | 120| appLabelId | string | No | No | Label ID corresponding to the icon name. | 121| bundleName | string | No | No | Bundle name corresponding to the icon.| 122| abilityName | string | No | No | Application ability name corresponding to the icon.| 123| details | Record<string, number \| string \| Uint8Array> | No | Yes | Object of the dictionary type used to describe the icon. The key is of the string type, and the value can be a number, a string, or a Uint8Array. By default, it is an empty dictionary object.| 124 125 126**Example** 127 128```ts 129let u8Array = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); 130let appItemDetails : Record<string, number | string | Uint8Array> = { 131 'appItemKey1': 123, 132 'appItemKey2': 'appItemValue', 133 'appItemKey3': u8Array, 134} 135let appItem : uniformDataStruct.OpenHarmonyAppItem = { 136 uniformDataType:'openharmony.app-item', 137 appId : 'MyAppId', 138 appName : 'MyAppName', 139 appIconId : 'MyAppIconId', 140 appLabelId : 'MyAppLabelId', 141 bundleName : 'MyBundleName', 142 abilityName : 'MyAbilityName', 143 details : appItemDetails, 144} 145console.info('appItem.uniformDataType: ' + appItem.uniformDataType); 146``` 147