Data acquisition method, device, system, browser and storage medium
By obtaining and analyzing the response messages forwarded by cloud services in the browser, determining the target number to ensure data integrity, the problem of response messages truncation under the cloud platform is solved, and the stability and integrity of browser data analysis is achieved .
Patent Information
- Application Number
- CN202411573818.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2044-11-05
AI Technical Summary
Under the cloud platform, the data transmission between the browser and the terminal device may cause the response packet to be truncated due to the cloud service's limit on the amount of response packets, resulting in errors and abnormal interface display when the browser parses data.
By obtaining the response packet forwarded by the cloud service, determining its data format and integrity, calculating the maximum data volume and target number of items for a single transmission, and requesting data according to the target number to ensure data integrity and prevent truncation.
It effectively avoids errors and interface exceptions when analyzing data by the browser, ensuring data integrity and consistency.
Smart Images

Figure CN119071283B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data transmission, and in particular to a data acquisition method, device, system, browser and storage medium. Background Art
[0002] Currently, many manufacturers support cloud platforms to manage terminal devices. In this case, data cannot be directly transmitted between the browser and the terminal device, and the device protocol needs to be transparently transmitted through the cloud service. For example, the browser sends a request message to the cloud service, and the cloud service has a built-in transparent transmission service. The transparent transmission service does not process the request message and directly forwards the request message to the terminal device. After the terminal device responds to the request message, it returns the response message to the cloud service, and the cloud service forwards the response message to the browser. In this way, the protocol transparent transmission between the browser and the terminal device is realized, and some device configuration and control functions can be performed.
[0003] In the above protocol transparent transmission process, considering the transmission performance and transmission speed, the cloud service will control the data volume of the response message. For example, the maximum data volume of a single transmission is 16KB. Under this restriction, if the data volume of the response message is large, the cloud service will truncate the response message. This will cause the browser to report an error when parsing the data, and the complete data cannot be obtained, resulting in abnormal interface display. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a data acquisition method, device, system, browser and storage medium to prevent the cloud service from truncating the response message, thereby preventing the browser from reporting an error when parsing the data, and avoiding the problem of abnormal interface display due to the browser's inability to obtain complete data. The specific technical solution is as follows:
[0005] In a first aspect, an embodiment of the present application provides a data acquisition method, which is applied to a browser, wherein the browser sends a request message to a terminal device through a cloud service, and the terminal device responds to the request message and returns a response message to the browser through the cloud service. The method includes:
[0006] Obtaining a response message forwarded by the cloud service;
[0007] Determine whether the response message is truncated by using a data integrity determination method corresponding to the data format of the response message;
[0008] If the response message is truncated, determine the target number of data items included in the response message of the data format that can be transmitted by the cloud service at a single time according to the maximum amount of data that can be transmitted by the cloud service at a single time and the data format of the response message;
[0009] According to the target number of items, data is requested from the cloud service, so that the cloud service returns data to the browser according to the target number of items.
[0010] Optionally, the response message includes an array node and a non-array node, and the array node includes multiple child nodes;
[0011] The step of determining, based on the maximum amount of data that can be transmitted by the cloud service at a single time and the data format of the response message, a target number of data items included in the response message of the data format that can be transmitted by the cloud service at a single time comprises:
[0012] Determine the amount of data of array nodes included in the response message that can be transmitted by the cloud service at a single time according to the maximum amount of data that can be transmitted by the cloud service at a single time and the amount of data of non-array nodes included in the response message;
[0013] Counting the amount of data of each sub-node in the array node included in the response message, and determining a maximum value from the amount of data;
[0014] The quotient between the amount of data of the array nodes included in the response message that the cloud service can transmit at one time and the maximum value is calculated to obtain the target number of data items included in the response message of the data format that the cloud service can transmit at one time.
[0015] Optionally, the step of determining the amount of data of array nodes included in the response message that can be transmitted by the cloud service at a single time according to the maximum amount of data that can be transmitted by the cloud service at a single time and the amount of data of non-array nodes included in the response message, comprises:
[0016] Calculate the difference between the maximum amount of data that can be transmitted by the cloud service at one time and the amount of data of the non-array node;
[0017] The difference between the difference and the preset reserved data volume is calculated to obtain the data volume of the array nodes included in the response message that can be transmitted by the cloud service at a single time.
[0018] Optionally, the step of counting the amount of data of each sub-node in the array node included in the response message includes at least one of the following:
[0019] If the response message is in XML format, traverse each node in the response message in order, and for each node traversed, determine whether the name identifier of the node is the name identifier corresponding to the array node; if the name identifier of the node is the name identifier corresponding to the array node, determine that the node is an array node, and use the data amount included between each pair of start name identifier and end name identifier in the node as the data amount of each child node;
[0020] If the response message is in JSON format, traverse each node in the response message in order, and for each node traversed to, determine whether the name identifier of the node is the name identifier corresponding to the array node; if the name identifier of the node is the name identifier corresponding to the array node, determine that the node is an array node, and use the data amount of the child node where the name identifier corresponding to each child node in the node is located as the data amount of each child node.
[0021] Optionally, the step of determining whether the response message is truncated by using a data integrity determination method corresponding to the data format of the response message includes at least one of the following:
[0022] If the response message is in XML format, traverse the fields included in the response message to determine whether the response message includes a message end tag; if the response message does not include a message end tag, determine that the response message is truncated;
[0023] If the response message is in XML format, calling a data integrity determination function corresponding to the XML format, parsing the response message to obtain a parsing result; if there is a node indicating a parsing error in the parsing result, determining that the response message is truncated;
[0024] If the response message is in JSON format, call the data integrity determination function corresponding to the JSON format to parse the response message; if the data integrity determination function corresponding to the JSON format reports an error, it is determined that the response message is truncated.
[0025] Optionally, the terminal where the browser is located is deployed with a local service, and the cloud service is deployed with a transparent transmission service;
[0026] The step of obtaining the response message forwarded by the cloud service includes at least one of the following:
[0027] The browser obtains a response message forwarded by the cloud service, wherein the request message is sent by the browser to the cloud service and sent by the transparent transmission service to the terminal device;
[0028] The local service obtains a response message forwarded by the cloud service, wherein the request message is sent by the local service to the cloud service and sent by the transparent transmission service to the terminal device;
[0029] The browser obtains a response message sent by the cloud service, wherein the response message is obtained by parsing the response data sent by the cloud service to the transparent transmission service from the terminal device, and the request message is sent by the browser to the cloud service and sent by the transparent transmission service to the terminal device.
[0030] Optionally, the browser includes a web page;
[0031] The method further comprises:
[0032] After acquiring the data returned by the cloud service to the browser according to the target number of items, the data returned to the browser is parsed, and the parsed data is displayed on the web page.
[0033] In a second aspect, an embodiment of the present application provides a data acquisition device, which is applied to a browser, wherein the browser sends a request message to a terminal device through a cloud service, and the terminal device responds to the request message and returns a response message to the browser through the cloud service, wherein the device includes:
[0034] A response message acquisition module, used to acquire the response message forwarded by the cloud service;
[0035] A response message determination module, used to determine whether the response message is truncated by using a data integrity determination method corresponding to the data format of the response message;
[0036] a target number determination module, configured to determine, if the response message is truncated, a target number of data items included in the response message of the data format that can be transmitted by the cloud service at a single time, based on the maximum amount of data that can be transmitted by the cloud service at a single time and the data format of the response message;
[0037] The data request module is used to request data from the cloud service according to the target number of items, so that the cloud service returns data to the browser according to the target number of items.
[0038] Optionally, the response message includes an array node and a non-array node, and the array node includes multiple child nodes;
[0039] The target number determination module includes:
[0040] A data volume determination submodule, configured to determine the amount of data of array nodes included in the response message that the cloud service can transmit at a single time, based on the maximum amount of data that the cloud service can transmit at a single time and the amount of data of non-array nodes included in the response message;
[0041] A maximum value determination submodule, used to count the amount of data of each sub-node in the array node included in the response message, and determine the maximum value from the data amount;
[0042] The target number calculation submodule is used to calculate the quotient between the amount of data of the array nodes included in the response message that the cloud service can transmit at one time and the maximum value, and obtain the target number of data included in the response message of this data format that the cloud service can transmit at one time.
[0043] Optionally, the data volume determination submodule includes:
[0044] A difference calculation unit, used to calculate the difference between the maximum amount of data that can be transmitted by the cloud service at a single time and the amount of data of the non-array node;
[0045] The data volume calculation unit is used to calculate the difference between the difference and the preset reserved data volume, and obtain the data volume of the array nodes included in the response message that can be transmitted by the cloud service at a single time.
[0046] Optionally, the maximum value determination submodule includes:
[0047] A first data volume determination unit is used for, if the response message is in XML format, sequentially traversing each node in the response message, and for each traversed node, determining whether the name identifier of the node is the name identifier corresponding to the array node; if the name identifier of the node is the name identifier corresponding to the array node, determining that the node is an array node, and taking the data volume of the data included between each pair of the start name identifier and the end name identifier in the node as the data volume of each child node;
[0048] The second data volume determination unit is used to traverse each node in the response message in order if the response message is in JSON format, and determine whether the name identifier of each node is the name identifier corresponding to the array node each time the node is traversed; if the name identifier of the node is the name identifier corresponding to the array node, determine that the node is an array node, and use the data volume of the child node where the name identifier corresponding to each child node in the node is located as the data volume of each child node.
[0049] Optionally, the response message determination module includes:
[0050] A first response message determination submodule, for traversing each field included in the response message if the response message is in XML format, and determining whether the response message includes a message end tag; if the response message does not include a message end tag, determining that the response message is truncated;
[0051] A second response message determination submodule is used to, if the response message is in XML format, call a data integrity determination function corresponding to the XML format, parse the response message, and obtain a parsing result; if there is a node indicating a parsing error in the parsing result, determine that the response message is truncated;
[0052] The third response message determination submodule is used to call the data integrity determination function corresponding to the JSON format to parse the response message if the response message is in the JSON format; if the data integrity determination function corresponding to the JSON format reports an error, it is determined that the response message is truncated.
[0053] Optionally, the terminal where the browser is located is deployed with a local service, and the cloud service is deployed with a transparent transmission service;
[0054] The response message acquisition module includes:
[0055] A first response message acquisition submodule, used for the browser to acquire a response message forwarded by the cloud service, wherein the request message is sent by the browser to the cloud service and sent by the transparent transmission service to the terminal device;
[0056] A second response message acquisition submodule, used for the local service to acquire a response message forwarded by the cloud service, wherein the request message is sent by the local service to the cloud service and sent by the transparent transmission service to the terminal device;
[0057] The third response message acquisition submodule is used for the browser to obtain a response message sent by the cloud service, wherein the response message is obtained by parsing the response data sent by the cloud service to the transparent transmission service from the terminal device, and the request message is sent by the browser to the cloud service and sent by the transparent transmission service to the terminal device.
[0058] Optionally, the browser includes a web page;
[0059] The device also includes:
[0060] The data display module is used to parse the data returned to the browser after acquiring the data returned by the cloud service to the browser according to the target number of items, and display the parsed data in the web page.
[0061] In a third aspect, an embodiment of the present application provides a data acquisition system, the data acquisition system comprising a browser, a cloud service, and a terminal device, wherein:
[0062] The browser is used to send a request message to the terminal device through the cloud service,
[0063] The terminal device is used to respond to the request message and return a response message to the browser through the cloud service;
[0064] The cloud service is further used to forward the response message to the browser;
[0065] The browser is also used to execute the method described in any one of the first aspects above.
[0066] In a fourth aspect, an embodiment of the present application provides a browser, including:
[0067] Memory, used to store computer programs;
[0068] The processor is used to implement any method described in the first aspect when executing a program stored in the memory.
[0069] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any method described in the first aspect is implemented.
[0070] Beneficial effects of the embodiments of the present application:
[0071] In the scheme provided by the embodiment of the present application, the browser can obtain the response message forwarded by the cloud service; determine whether the response message is truncated by the data integrity determination method corresponding to the data format of the response message; if the response message is truncated, determine the target number of data included in the response message of the data format that the cloud service can transmit at a time according to the maximum amount of data that the cloud service can transmit at a time and the data format of the response message; according to the target number of data, request data from the cloud service so that the cloud service returns data to the browser according to the target number of data. In the case where the response message is truncated by the cloud service, the browser can determine the target number of data included in the response message of the data format that the cloud service can transmit at a time according to the maximum amount of data that the cloud service can transmit at a time and the data format of the response message. The response message includes array nodes and non-array nodes. Since the data format of the response message can reflect the amount of data occupied by array nodes and non-array nodes in the response message of the data format, the target number of data that the cloud service can transmit at a time can be determined based on the maximum amount of data that the cloud service can transmit at a time and the data format of the response message, and the data is the sub-nodes included in the array node. Next, the browser can request data from the cloud service according to the target number of items, and the cloud service can return data to the browser according to the target number of items. Since the amount of data of the target number of items can meet the limit of the maximum amount of data transmitted by the cloud service in a single time, it can be guaranteed that the data in the response message returned by the cloud service is not truncated, thereby avoiding the browser from reporting an error when parsing the data, and avoiding the problem of abnormal interface display due to the browser's inability to obtain complete data. Of course, implementing any product or method of the present application does not necessarily require achieving all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other embodiments can also be obtained based on these drawings.
[0073] Figure 1 A flowchart of a data acquisition method provided in an embodiment of the present application;
[0074] Figure 2 for Figure 1 A specific flow chart of step S103 in the illustrated embodiment;
[0075] Figure 3 for Figure 2 A specific flow chart of step S201 in the illustrated embodiment;
[0076] Figure 4 Based on Figure 1 A schematic diagram of the network architecture of the illustrated embodiment;
[0077] Figure 5 Based on Figure 1 A flow chart of the browser of the illustrated embodiment initiating a protocol request to a terminal device;
[0078] Figure 6 Based on Figure 1 A flow chart of a browser obtaining data from a cloud service in the illustrated embodiment;
[0079] Figure 7 A schematic diagram of the structure of a data acquisition device provided in an embodiment of the present application;
[0080] Figure 8 A structural diagram of a data acquisition system provided in an embodiment of the present application;
[0081] Figure 9 A schematic diagram of the structure of a browser provided in an embodiment of the present application. DETAILED DESCRIPTION
[0082] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.
[0083] In order to prevent the cloud service from truncating the response message, thereby preventing the browser from reporting an error when parsing the data, and avoiding the problem of abnormal interface display due to the browser's inability to obtain complete data, the embodiments of the present application provide a data acquisition method, device, system, browser, computer-readable storage medium, and computer program product. First, a data acquisition method provided by the embodiments of the present application is introduced.
[0084] The data acquisition method provided in the embodiment of the present application can be applied to any browser that needs to acquire data from a cloud service, for example, a browser of a mobile terminal or a browser of a desktop terminal, which is not specifically limited here. For the sake of clarity, it is referred to as a browser in the following text.
[0085] like Figure 1 As shown, a data acquisition method is applied to a browser, wherein the browser sends a request message to a terminal device through a cloud service, and the terminal device responds to the request message and returns a response message to the browser through the cloud service. The method includes:
[0086] S101, obtaining a response message forwarded by the cloud service;
[0087] S102, determining whether the response message is truncated by a data integrity determination method corresponding to the data format of the response message; if the response message is truncated, executing steps S103 to S105; if the response message is not truncated, executing step S105;
[0088] S103, determining a target number of data items included in a response message of the data format that can be transmitted by the cloud service at a single time according to the maximum amount of data that can be transmitted by the cloud service at a single time and the data format of the response message;
[0089] S104, requesting data from the cloud service according to the target number of items, so that the cloud service returns data to the browser according to the target number of items;
[0090] S105, parsing the response message and displaying the parsed data.
[0091] It can be seen that in the embodiment of the present application, the browser can obtain the response message forwarded by the cloud service; determine whether the response message is truncated by the data integrity determination method corresponding to the data format of the response message; if the response message is truncated, determine the target number of data included in the response message of the data format that the cloud service can transmit at a time according to the maximum amount of data that the cloud service can transmit at a time and the data format of the response message; according to the target number of data, request data from the cloud service so that the cloud service returns data to the browser according to the target number of data. In the case where the response message is truncated by the cloud service, the browser can determine the target number of data included in the response message of the data format that the cloud service can transmit at a time according to the maximum amount of data that the cloud service can transmit at a time and the data format of the response message. The response message includes array nodes and non-array nodes. Since the data format of the response message can reflect the amount of data occupied by array nodes and non-array nodes in the response message of the data format, based on the maximum amount of data that the cloud service can transmit at a time and the data format of the response message, the target number of data that the cloud service can transmit at a time can be determined, and the data is the sub-nodes included in the array node. Next, the browser can request data from the cloud service according to the target number of entries, and the cloud service can return data to the browser according to the target number of entries. Since the amount of data in the target number of entries can meet the maximum amount of data that the cloud service can transmit at a time, it can be guaranteed that the data in the response message returned by the cloud service is not truncated, thereby avoiding errors when the browser parses the data and avoiding abnormal interface display due to the browser's inability to obtain complete data.
[0092] In the protocol transparent transmission scenario, when the user needs to obtain the data collected by the terminal device, he can access the cloud service through the browser and send a request message to the terminal device through the cloud service. In response to the request message sent by the cloud service, the terminal device can return a response message to the browser through the cloud service, and the browser can obtain the response message forwarded by the cloud service, that is, execute step S101.
[0093] The terminal device may be a device with a data collection function, for example, a PTZ camera, a network camera, an analog camera, etc. The request protocol of the request message may be a paging request or a synchronization request, which is not specifically limited here.
[0094] The maximum amount of data that a cloud service can transmit at a time is usually determined. If the amount of data in the response message exceeds the maximum amount of data, the cloud service will truncate the response message. The response message has a variety of data formats, and different data formats correspond to different data integrity determination methods. Therefore, in order to determine whether the obtained response message is truncated, the browser can determine whether the response message is truncated by using the data integrity determination method corresponding to the data format of the response message, that is, executing step S102.
[0095] For example, the data format of the response message may be in XML (Extensible Markup Language) format or JSON (JavaScript Object Notation) format. The data integrity determination method corresponding to the XML format may be by determining whether the response message includes a message end tag, or may be an API (Application Programming Interface) method provided by JavaScript (Java script), and the API method may specifically be a parseFromString (string parsing) function provided by a DOMParser (Document Object ModelParser) object. The data integrity determination method corresponding to the JSON format may be an API method provided by JavaScript, and the API method may specifically be a JSON.parse() function.
[0096] The response message usually includes array nodes and non-array nodes. For example, when the request protocol is a paging request, the array node can be paging data. The amount of non-array node data included in each response message is related to the data format of the response message. Specifically, the amount of non-array node data included in response messages of the same data format is usually fixed, and the amount of non-array node data included in response messages of different data formats may be different.
[0097] If the response message is truncated, it means that the array node in the response message may be truncated, which will cause the browser to report an error when parsing the data, fail to obtain complete data, and cause abnormal interface display. In order to avoid the above problem, the browser can execute the above step S103, that is, according to the maximum amount of data that the cloud service can transmit at a time and the data format of the response message, determine the target number of data items included in the response message of the data format that the cloud service can transmit at a time.
[0098] The data is the child nodes included in the array node, that is, the target number determined by the browser corresponds to the child nodes in the array node. The target number can be the maximum number of data that can be included in a response message, or it can be less than the maximum number, which is reasonable.
[0099] After the browser determines the target number of items, it can request data from the cloud service according to the target number of items, that is, execute step S104. After receiving the request, the cloud service can return data to the browser according to the target number of items. In this way, it can be ensured that the number of data items contained in the response message subsequently returned by the cloud service meets the data format restrictions of the response message, thereby ensuring that the data will not be truncated and is complete, achieving the effect of data completion. The browser can then parse the response message subsequently returned by the cloud service and display the parsed data, that is, execute the above step S105.
[0100] If the response message is not truncated, it means that the data in the response message is complete, then the browser can parse the response message and display the parsed data, that is, execute the above step S105.
[0101] It can be seen that in the embodiment of the present application, when the response message is truncated by the cloud service, the browser can determine the target number of data included in the response message of the data format that the cloud service can transmit at a time based on the maximum amount of data that the cloud service can transmit at a time and the data format of the response message. The response message includes array nodes and non-array nodes. Since the data format of the response message can reflect the amount of data occupied by array nodes and non-array nodes in the response message of the data format, the target number of data that the cloud service can transmit at a time can be determined based on the maximum amount of data that the cloud service can transmit at a time and the data format of the response message, and the data is the sub-nodes included in the array node. Next, the browser can request data from the cloud service according to the target number of items, and the cloud service can return data to the browser according to the target number of items. Since the cloud service returns data according to the target number of items, it can be guaranteed that the data in the response message returned by the cloud service is not truncated, thereby avoiding the browser from reporting an error when parsing the data, and avoiding the problem of abnormal interface display due to the browser's inability to obtain complete data.
[0102] As an implementation method of an embodiment of the present application, the above response message may include an array node and a non-array node, and an array node may include multiple child nodes. In this case, Figure 2 As shown, the step of determining the target number of data items included in the response message of the data format that can be transmitted by the cloud service at a single time according to the maximum amount of data that can be transmitted by the cloud service at a single time and the data format of the response message may include:
[0103] S201, determining the amount of data of array nodes included in the response message that the cloud service can transmit at a single time according to the maximum amount of data that the cloud service can transmit at a single time and the amount of data of non-array nodes included in the response message;
[0104] Since the response message usually includes array nodes and non-array nodes, and the data volume of the non-array nodes can be determined based on the data format of the response message, the browser can determine the data volume of the array nodes included in the response message that the cloud service can transmit at a single time based on the maximum data volume that the cloud service can transmit at a single time and the data volume of the non-array nodes included in the response message.
[0105] In one implementation, the browser may calculate the difference between the maximum data volume and the data volume of non-array nodes included in the response message, and obtain the data volume of array nodes included in the response message that the cloud service can transmit at one time.
[0106] S202, counting the amount of data of each child node in the array node included in the response message, and determining a maximum value from the amount of data;
[0107] The array node includes multiple child nodes, and the target number is the number of child nodes in the array node included in the response message that the cloud service can transmit at a single time. The number of child nodes in the array node included in the response message can be determined based on the amount of data of the array node included in the response message and the amount of data of a single child node.
[0108] The data volume of different child nodes in an array node may be different. If the data volume of a single child node used for calculation is small, the calculated target number will be larger, which will cause the total data volume of the array node returned according to the target number to be larger than the data volume of the array node that can be included in the response message.
[0109] Therefore, the browser can count the data volume of each child node in the array node included in the response message, and determine the maximum value from the data volume of each child node in the array node. Then, the browser can use the maximum value as the data volume of a single child node in the array node to calculate the target number of items, so as to ensure that the total data volume of the child nodes in the array node returned according to the target number of items meets the data volume limit of the array node that can be included in the response message to the greatest extent.
[0110] The above steps S201 and S202 are described in order, but are not used to limit the order of execution. The order of execution can be step S201 and step S202, or step S202 and step S201, which is not specifically limited here.
[0111] S203, calculating the quotient between the amount of data of the array nodes included in the response message that the cloud service can transmit at one time and the maximum value, and obtaining the target number of data items included in the response message of the data format that the cloud service can transmit at one time.
[0112] After determining the maximum value of the amount of data of the array node included in the response message that the cloud service can transmit at one time and the amount of data of a single sub-node, the browser can calculate the quotient between the amount of data of the array node included in the response message and the maximum value, thereby obtaining the target number of sub-nodes in the array node included in the response message of the data format that the cloud service can transmit at one time. Assuming that the quotient is not an integer, the quotient can be rounded down and the result of the rounding down is used as the target number.
[0113] For example, assuming that the maximum data volume is 16KB and the data volume of non-array nodes is 2KB, then it can be calculated that the data volume of array nodes included in the response message that the cloud service can transmit at a time is 14KB. Assuming that the response message includes subnodes 1 to 8, the corresponding data volumes are 1.6KB, 1.8KB, 1.8KB, 1.9KB, 1.7KB, 1.7KB, 1.9KB and 2KB respectively, then the maximum value of 2KB can be determined from these data volumes, and then the quotient of 14KB of the data volume of the array nodes included in the response message and the maximum value of 2KB, 7, is used as the target number.
[0114] It can be seen that in the embodiment of the present application, the browser can determine the amount of data of the array nodes included in the response message that the cloud service can transmit at a time based on the maximum amount of data that the cloud service can transmit at a time and the amount of data of the non-array nodes included in the response message; count the amount of data of each sub-node in the array node included in the response message, and determine the maximum value from the amount of data; calculate the quotient between the amount of data of the array nodes included in the response message that the cloud service can transmit at a time and the maximum value, and obtain the target number of data included in the response message of the data format that the cloud service can transmit at a time. Since the calculation of the target number is based on the maximum amount of data of a single sub-node in the array node, it can be ensured that the total amount of data of the sub-nodes in the array node returned according to the target number meets the limit of the amount of data of the array node that can be included in the response message, thereby avoiding the data returned by the cloud service according to the target number from being truncated.
[0115] As an implementation method of the present application, Figure 3 As shown, the step of determining the amount of data of the array nodes included in the response message that can be transmitted by the cloud service at a single time according to the maximum amount of data that can be transmitted by the cloud service at a single time and the amount of data of the non-array nodes included in the response message may include:
[0116] S301, calculating the difference between the maximum amount of data that can be transmitted by the cloud service at one time and the amount of data of the non-array node;
[0117] Since the amount of data of non-array nodes included in the response message is usually fixed, the browser can calculate the difference between the maximum amount of data that the cloud service can transmit at a time and the amount of data of non-array nodes, and the difference is the amount of data of array nodes included in the response message that the cloud service can transmit at a time.
[0118] S302, calculating the difference between the difference and the preset reserved data volume, and obtaining the data volume of the array nodes included in the response message that the cloud service can transmit at a single time.
[0119] Although the data volume of a single subnode in an array node is the maximum value of the data volume of each array node included in the truncated response message, the subnodes of the array node included in the truncated response message are usually only a part of all the subnodes of the array node to be returned by the terminal device. Among the subnodes of the array node that the cloud service has not yet forwarded, there may be subnodes whose corresponding data volume is greater than the above maximum value. Therefore, in order to ensure that the response message will not be truncated, the reserved data volume can be set in advance. Among them, the reserved data volume can be set according to actual needs, for example, it can be 1KB, 2KB, and 3KB, etc., which are all reasonable.
[0120] Next, the browser can calculate the difference between the maximum amount of data that the cloud service can transmit at one time and the amount of data of non-array nodes, and then calculate the difference between the difference and the reserved data amount to obtain the amount of data of array nodes included in the response message that the cloud service can transmit at one time.
[0121] In this case, the target number can be calculated based on the following formula:
[0122] Target number of entries = (maximum data volume - data volume of non-array nodes - reserved data volume) / maximum data volume;
[0123] The maximum data volume is the maximum data volume that the cloud service can transmit at one time. The maximum data volume is the maximum value of the data volume of each sub-node in the array node included in the response message. The method for determining the data volume of each sub-node in the array node included in the response message is related to the data format of the response message.
[0124] When the response message is in XML format, the data amount of each child node in the array node can be marked by the start name. <searchmatchitem>and the end name identifier< / searchmatchitem> When the response message is in JSON format, the data volume of each child node in the array node may be the data volume of the data included in the child node containing the name identifier searchMatchItem corresponding to the child node.
[0125] For example, assuming that the maximum data volume is 16KB, the data volume of non-array nodes is 2KB, and the reserved data volume is 2KB, then it can be calculated that the data volume of the array nodes included in the response message that the cloud service can transmit at a time is 12KB. Assuming that the maximum value of the data volume of each sub-node in the array node included in the response message is 2KB, the quotient value 6 between the data volume of the array node included in the response message 12KB and the maximum value 2KB can be calculated as the target number.
[0126] It can be seen that in the embodiment of the present application, the browser can calculate the difference between the maximum amount of data that the cloud service can transmit at a time and the amount of data of the non-array node; calculate the difference between the difference and the preset reserved data amount, and obtain the amount of data of the array node included in the response message that the cloud service can transmit at a time. Even if there are child nodes in the array node that the cloud service subsequently forwards, whose corresponding data amount is greater than the maximum value of the child node data amount in the array node included in the current response message, due to the existence of the reserved data amount, it can be guaranteed to the greatest extent that the response message will not be truncated.
[0127] As an implementation of an embodiment of the present application, the step of counting the amount of data of each sub-node in the array node included in the response message may include at least one of the following two implementations:
[0128] If the response message is in XML format, traverse each node in the response message in order, and for each node traversed, determine whether the name identifier of the node is the name identifier corresponding to the array node; if the name identifier of the node is the name identifier corresponding to the array node, determine that the node is an array node, and use the data amount included between each pair of start name identifier and end name identifier in the node as the data amount of each child node;
[0129] If the response message is in JSON format, traverse each node in the response message in order, and for each node traversed to, determine whether the name identifier of the node is the name identifier corresponding to the array node; if the name identifier of the node is the name identifier corresponding to the array node, determine that the node is an array node, and use the data amount of the child node where the name identifier corresponding to each child node in the node is located as the data amount of each child node.
[0130] In the first implementation, since there is a specific name identifier for the array node in XML format, each node in the response message can be traversed in order to determine whether the name identifier corresponding to the traversed node is the name identifier corresponding to the above array node. If the name identifier corresponding to the traversed node is the name identifier corresponding to the above array node, then it can be determined that the node is an array node.
[0131] Since each child node in the XML format array node has a specific start name identifier and end name identifier, the start name identifier can be <searchmatchitem>, the end name identifier can be< / searchmatchitem> Therefore, after determining that the node is an array node, the amount of data included between each pair of start name identifiers and end name identifiers in the node, that is, the size of the data block between the start name identifier and the end name identifier of each child node in the node, can be used as the data amount of each child node.
[0132] For example, the request message in XML format can be:
[0133] <?xml version="1.0" encoding="UTF-8"?>
[0134] <cmsearchdescription xmlns="http: / / www.xxx" version="2.0">
[0135] <searchid>xxxx-xxxx-xxxx-xxxx< / searchid>
[0136] <timespanlist>
[0137] <timespan>
[0138] <starttime> 2024-08-04T00:00:00< / starttime>
[0139] <endtime> 2024-08-04T23:59:59< / endtime>
[0140] < / timespan>
[0141] < / timespanlist>
[0142] <searchresultpostion> 1< / searchresultpostion>
[0143] <maxresults> 100< / maxresults>
[0144] < / cmsearchdescription>
[0145] The browser can send the above request message to the terminal device through the cloud service. The terminal device responds to the request message and can generate a response message as shown below:
[0146] <?xml version="1.0" encoding="UTF-8"?>
[0147] <cmsearchresult xmlns="http: / / www.xxx" version="2.0">
[0148] <searchid>xxxx-xxxx-xxxx-xxxx< / searchid>
[0149] <responsestatus>ok< / responsestatus>
[0150] <responsestatusstrg>OK< / responsestatusstrg>
[0151] <numofmatches> 100< / numofmatches>
[0152] <matchlist>
[0153] <searchmatchitem>
[0154] <logdescriptor>
[0155] <metaid>< / metaid>
[0156] <startdatetime>
[0157] < / startdatetime>
[0158] <localid>< / localid>
[0159] <paratype>< / paratype>
[0160] <username>< / username>
[0161] <loginfo>< / loginfo>
[0162] <ipaddress>< / ipaddress>
[0163] <additioninformation><!--Additional information-->< / additioninformation>
[0164] < / logdescriptor>
[0165] < / searchmatchitem>
[0166] N is omitted here <searchmatchitem> …< / searchmatchitem>
[0167] <searchmatchitem>
[0168] <logdescriptor>
[0169] <metaid>< / metaid>
[0170] <startdatetime>< / startdatetime>
[0171] <localid>< / localid>
[0172] <paratype>< / paratype>
[0173] <username>< / username>
[0174] <loginfo>< / loginfo>
[0175] <ipaddress>< / ipaddress>
[0176] <additioninformation><!--Additional information-->< / additioninformation>
[0177] < / logdescriptor>
[0178] < / searchmatchitem>
[0179] < / matchlist>
[0180] < / cmsearchresult>
[0181] Among them, an adjacent pair of start name identifiers <searchmatchitem>and the end name identifier< / searchmatchitem> The data between is the data of a sub-node in the array node. A sub-node in the array node can be:
[0182] <searchmatchitem>
[0183] <logdescriptor>
[0184] <metaid>< / metaid>
[0185] <startdatetime>
[0186] < / startdatetime>
[0187] <localid>< / localid>
[0188] <paratype>< / paratype>
[0189] <username>< / username>
[0190] <loginfo>< / loginfo>
[0191] <ipaddress>< / ipaddress>
[0192] <additioninformation><!--Additional information-->< / additioninformation>
[0193] < / logdescriptor>
[0194] < / searchmatchitem>
[0195] It is understandable that "N is omitted here <searchmatchitem> …< / searchmatchitem> " is not the original data contained in the response message, but for the convenience of description, it means that N child nodes in the array node are omitted.
[0196] In the second implementation, since the array node in JSON format has a name identifier corresponding to the array node, the browser can traverse each node in the response message in order, and each time a node is traversed, determine whether the name identifier of the node is the name identifier corresponding to the array node. The name identifier corresponding to the array node can be searchMatchItem.
[0197] If the name identifier of the node is the name identifier corresponding to the array node, then the node can be determined to be an array node, and the data amount of the child node where the name identifier corresponding to each child node in the node is located, that is, the data block size of the object where the name identifier corresponding to the child node of the array node is located, is used as the data amount of each child node in the array node. Specifically, the left curly bracket adjacent to the name identifier corresponding to the child node can be determined before the name identifier corresponding to the child node, and the right curly bracket corresponding to the left curly bracket can be determined after the name identifier corresponding to the child node, and the data amount of the data between the determined left curly bracket and the right curly bracket is used as the data amount of each child node.
[0198] For example, the request message in JSON format can be:
[0199] {
[0200] CMSearchDescription: {
[0201] searchID: 'xxxx-xxxx-xxxx-xxxx',
[0202] timeSpanList: {
[0203] timeSpan: {
[0204] startTime: '2024-08-04T00:00:00',
[0205] endTime: '2024-08-04T23:59:59'
[0206] }
[0207] },
[0208] searchResultPosition: 1,
[0209] maxResults: 100
[0210] }
[0211] }
[0212] The browser can send the above request message to the terminal device through the cloud service. The terminal device responds to the request message and can generate a response message as shown below:
[0213] {
[0214] CMSearchResult: {
[0215] searchID: 'xxxx-xxxx-xxxx-xxxx',
[0216] responseStatus: 'ok',
[0217] responseStatusStrg: 'OK',
[0218] numOfMatches: 100,
[0219] matchList:
[0220] {
[0221] searchMatchItem: {
[0222] logDescriptor: {
[0223] metaId: '',
[0224] startDateTime: '',
[0225] localID: '',
[0226] paraType: '',
[0227] userName: '',
[0228] logInfo: '',
[0229] ipAddress: '',
[0230] additionInformation: ''
[0231] }
[0232] }
[0233] },
[0234] {
[0235] N {searchMatchItem: {...}} are omitted here
[0236] },
[0237] {
[0238] searchMatchItem: {
[0239] logDescriptor: {
[0240] metaId: '',
[0241] startDateTime: '',
[0242] localID: '',
[0243] paraType: '',
[0244] userName: '',
[0245] logInfo: '',
[0246] ipAddress: '',
[0247] additionInformation: ''
[0248] }
[0249] }
[0250] } ]
[0252] }
[0253] }
[0254] The object in matchlist[] can be an object node, the data between the first left curly brace before searchMatchItem and the right curly brace corresponding to the left curly brace can be the data of a child node, and a child node in the array node can be:
[0255] {
[0256] searchMatchItem: {
[0257] logDescriptor: {
[0258] metaId: '',
[0259] startDateTime: '',
[0260] localID: '',
[0261] paraType: '',
[0262] userName: '',
[0263] logInfo: '',
[0264] ipAddress: '',
[0265] additionInformation: ''
[0266] }
[0267] }
[0268] }
[0269] It is understandable that "N {searchMatchItem: {...}} omitted here" is not the original data contained in the response message, but for the convenience of description, it means that N child nodes in the array node are omitted.
[0270] It can be seen that in the embodiment of the present application, when the response message is in XML format and JSON format, the browser can use a corresponding method to determine the data amount of each child node in the array node included in the response message, and can quickly and accurately count the data amount of each child node in the array node.
[0271] As an implementation manner of an embodiment of the present application, the step of determining whether the response message is truncated by the data integrity determination method corresponding to the data format of the response message may include at least one of the following three implementation manners:
[0272] If the response message is in XML format, traverse the fields included in the response message to determine whether the response message includes a message end tag; if the response message does not include a message end tag, determine that the response message is truncated;
[0273] If the response message is in XML format, calling a data integrity determination function corresponding to the XML format, parsing the response message to obtain a parsing result; if there is a node indicating a parsing error in the parsing result, determining that the response message is truncated;
[0274] If the response message is in JSON format, call the data integrity determination function corresponding to the JSON format to parse the response message; if the data integrity determination function corresponding to the JSON format reports an error, it is determined that the response message is truncated.
[0275] In the first implementation, for a response message in XML format, there are a message start tag and a message end tag in the response message in this format, and the two appear in pairs, that is, a complete response message in XML format has a message start tag and a message end tag. The message start tag can be <cmsearchresult>, the message end tag can be< / cmsearchresult> .
[0276] Since the message start tag and message end tag are located at the beginning and end of the response message respectively, if the response message is truncated, the message end tag will usually be truncated, so the browser can traverse the fields included in the response message to determine whether the response message includes the message end tag. If the response message does not include the message end tag, it can be determined that the response message is truncated; if the response message includes the message end tag, it can be determined that the response message is not truncated.
[0277] For example, suppose that the following part of the XML response message above is truncated:
[0278] <paratype>< / paratype>
[0279] <username>< / username>
[0280] <loginfo>< / loginfo>
[0281] <ipaddress>< / ipaddress>
[0282] <additioninformation><!--Additional information-->< / additioninformation>
[0283]
[0284]
[0285]
[0286]
[0287] Then the response message will not have a message end tag, and the browser will determine that the response message is truncated.
[0288] In the second implementation, for the response message in XML format, assuming that the response message is truncated, the data integrity determination function corresponding to the XML format is called to parse the response message, and a node indicating a parsing error will be present in the obtained parsing result. Therefore, in order to determine whether the response message in XML format is truncated, the browser can call the data integrity determination function corresponding to the XML format, parse the response message, and obtain a parsing result. If there is a node indicating a parsing error in the parsing result, the browser can determine that the response message is truncated; if there is no node indicating a parsing error in the parsing result, the browser can determine that the response message is not truncated.
[0289] The data integrity determination function may be the parseFromString function provided by the DOMParser object. Assuming that the parseFromString function is called to parse the response message, and a parsererror (parse error) node exists in the obtained parsing result, it can be determined that the response message is incomplete, that is, the response message is truncated.
[0290] In the third implementation, for a response message in JSON format, assuming that the response message in this format is truncated, a data integrity determination function corresponding to the JSON format is called to parse the response message, and the data integrity determination function corresponding to the JSON format will report an error. The data integrity determination function may be a JSON.parse() function.
[0291] Therefore, in order to determine whether the response message in JSON format is truncated, the browser can call the data integrity determination function corresponding to the JSON format to parse the response message. If the data integrity determination function corresponding to the JSON format reports an error, it can be determined that the response message is truncated; if the data integrity determination function corresponding to the JSON format does not report an error, it can be determined that the response message is not truncated.
[0292] For example, suppose that the following part of the JSON response message above is truncated:
[0293] paraType: '',
[0294] userName: '',
[0295] logInfo: '',
[0296] ipAddress: '',
[0297] additionInformation: ''
[0298] }
[0299] }
[0300] } ]
[0302] }
[0303] }
[0304] Then the browser calls the JSON.parse() function to parse the received response message, and the JSON.parse() function will report an error, and the browser can determine that the response message is truncated.
[0305] Considering that data parsing can be implemented in the browser, the transparent service deployed in the cloud service, and the local service deployed in the terminal where the browser is located, and different technical implementations will have corresponding API methods to determine whether the response message is truncated, no specific restrictions are made. Among them, the browser and the local service are different applications and can be installed by the user.
[0306] For example, if implemented in a browser, the corresponding API method can be provided by JavaScript; if implemented in a transparent service, the corresponding API method can be provided by C++ (C Plus Plus) or Java; if implemented in a local service, the corresponding API method can be provided by Nodejs (Node JavaScript), and so on.
[0307] It can be seen that in the embodiment of the present application, the browser can adopt the first two implementations to determine whether the response message in XML format is truncated, and can also adopt the third implementation to determine whether the response message in JSON format is truncated. In this way, it is possible to quickly and accurately determine whether the response message in different formats is truncated for the response message, and then perform subsequent processing when it is determined that the response message is truncated.
[0308] As an implementation method of an embodiment of the present application, the terminal where the above-mentioned browser is located may be deployed with a local service, and the cloud service may be deployed with a transparent transmission service. In this case, the step of obtaining the response message forwarded by the cloud service may include at least one of the following three implementation methods:
[0309] The browser obtains a response message forwarded by the cloud service; or, the local service obtains a response message forwarded by the cloud service; or, the browser obtains a response message sent by the cloud service.
[0310] In the first implementation, the browser can obtain the response message forwarded by the cloud service. In this case, the request message is sent by the browser to the cloud service and sent to the terminal device by the transparent transmission service. Specifically, the browser can send a request message to the cloud service, and the transparent transmission service deployed in the cloud service sends the request message to the terminal device. The terminal device responds to the request message and sends a response message to the cloud service, and the cloud service forwards the response message to the browser. The browser parses and responds to the response message returned by the cloud service.
[0311] For example, a schematic diagram of the network architecture can be as follows Figure 4 As shown, the browser accesses the cloud service, sends a request message to the terminal device through the cloud service, the terminal device responds to the request message, and then returns the response message to the browser through the cloud service. Among them, the terminal device is a variety of camera devices, and the cloud service has a built-in transparent transmission service. Figure 4 Solution 1 corresponds to the first implementation method described above. In Solution 1, the browser sends a request message to the cloud service, parses and responds to the data returned by the cloud service.
[0312] In the second implementation, the local service can obtain the response message forwarded by the cloud service. In this case, the request message can be sent from the browser to the local service, sent from the local service to the cloud service, and sent to the terminal device by the transparent transmission service. Specifically, the local service deployed on the terminal where the browser is located sends the request message to the cloud service, and the transparent transmission service deployed on the cloud service sends the request message to the terminal device. The terminal device responds to the request message and sends a response message to the cloud service, which then forwards the response message to the local service. The local service can parse and respond to the response message returned by the cloud service, and return the parsed result to the browser.
[0313] Figure 4 Solution 2 in corresponds to the second implementation method described above. In Solution 2, the browser sends a request message to the local service, the local service sends a request message to the cloud service, the local service parses and responds to the data returned by the cloud service, and returns the parsed result to the browser.
[0314] In the third implementation, the browser can obtain the response message sent by the cloud service. In this case, the response message can be obtained by parsing the response data sent by the cloud service to the transparent transmission service from the terminal device, and the request message is sent by the browser to the cloud service and sent to the terminal device by the transparent transmission service.
[0315] Specifically, the browser can send a request message to the cloud service, and the transparent transmission service deployed in the cloud service sends the request message to the terminal device. The terminal device responds to the request message and returns the response data to the transparent transmission service. The cloud service parses the response data returned by the terminal device to the transparent transmission service, obtains the response message, and sends the response message to the browser. The browser parses and responds to the response message returned by the cloud service. Figure 4 Solution 3 in corresponds to the third implementation method described above. In Solution 3, the browser sends a request message to the cloud service, and the cloud service parses and responds to the response data returned by the transparent transmission service.
[0316] It can be seen that in the embodiments of the present application, in different network architecture scenarios, the browser can obtain the response message forwarded by the cloud service through the above three methods, which can provide users with a higher degree of freedom and ensure that the browser can successfully receive the response message returned by the cloud service in various network architecture scenarios.
[0317] As an implementation of an embodiment of the present application, the above-mentioned browser may include a web page. In this case, the above-mentioned method may also include:
[0318] After acquiring the data returned by the cloud service to the browser according to the target number of items, the data returned to the browser is parsed, and the parsed data is displayed on the web page.
[0319] Since the cloud service returns data according to the target number of items, and the array nodes of the target number of items meet the limit of the maximum amount of data that the cloud service can transmit at a time, the data returned by the cloud service according to the target number of items is complete. After obtaining the data returned by the cloud service, the browser can parse the returned data and display the parsed data on the web page for the user to view on the web interface.
[0320] It can be seen that in the embodiment of the present application, after obtaining the data returned by the cloud service to the browser according to the target number of items, the browser can parse the data returned to the browser and display the parsed data in the web page. In this way, the user can view the complete data returned by the cloud service in the web interface, and achieve the effect of completing the truncated data.
[0321] As an implementation method of the embodiment of the present application, a flowchart of a browser initiating a protocol request to a terminal device can be as follows: Figure 5 As shown, the following steps may be specifically included:
[0322] S501, the browser initiates a protocol request;
[0323] When the browser starts to request data from the terminal device, it can directly initiate a protocol request to the cloud service, or it can initiate a protocol request to the cloud service through a local service deployed on the terminal where the browser is located.
[0324] S502, local service forwarding protocol request;
[0325] After receiving the protocol request initiated by the browser, the local service can forward the protocol request to the cloud service.
[0326] S503, cloud service forwarding protocol request;
[0327] After receiving the protocol request sent directly by the browser or forwarded by the browser through the local service, the cloud service can forward the received protocol request to the terminal device. Among them, the cloud service can have a built-in transparent transmission service.
[0328] S504: The terminal device receives a protocol request.
[0329] After receiving the protocol request, the terminal device can respond to the protocol request, thus ending the process of the browser initiating the protocol request.
[0330] As an implementation method of the embodiment of the present application, a flow chart of a browser obtaining data from a cloud service can be as follows: Figure 6 As shown, the following steps may be specifically included:
[0331] S601, obtaining a response message returned by the cloud service;
[0332] After starting the process, the browser can obtain the response message returned by the cloud service, which is sent by the terminal device to the cloud service.
[0333] S602, determine the data format of the response message; if the data format of the response message is XML format, execute step S603; if the data format of the response message is JSON format, execute step S604;
[0334] Since different data formats correspond to different data integrity determination methods, after obtaining the response message, the browser can determine whether the data format of the response message is XML format or JSON format. If the data format of the response message is XML format, the browser can execute step S603; if the data format of the response message is JSON format, the browser can execute step S604.
[0335] S603, using the method corresponding to the XML format, determine whether the response message is truncated; if yes, execute step S605; if not, execute step S606;
[0336] When it is determined that the data format of the response message is in XML format, the browser can use the data integrity determination method corresponding to the XML format to determine whether the response message is truncated. Specifically, the browser can use the following two methods to determine:
[0337] In the first method, the browser can traverse the fields included in the response message to determine whether the response message includes a message end tag. If the response message does not include a message end tag, it can be determined that the response message is truncated; if the response message includes a message end tag, it can be determined that the response message is not truncated.
[0338] In the second method, the browser can call the parseFromString function to parse the response message and obtain a parsing result. If there is a parsererror node in the parsing result, it can be determined that the response message is truncated; if there is no parsererror node in the parsing result, it can be determined that the response message is not truncated.
[0339] S604, using a method corresponding to the JSON format, determine whether the response message is truncated; if yes, execute step S607; if no, execute step S606;
[0340] When it is determined that the data format of the response message is in JSON format, the browser can use the data integrity determination method corresponding to the JSON format to determine whether the response message is truncated. Specifically, the browser can call the JSON.parse() function to parse the response message. If the JSON.parse() function reports an error, it can be determined that the response message is truncated; if the JSON.parse() function does not report an error, it can be determined that the response message is not truncated.
[0341] S605, calculating the data volume of each child node in the XML format array node;
[0342] The browser can traverse each node in the response message in order, and each time it traverses to a node, it determines whether the name identifier of the node is the name identifier corresponding to the array node. If the name identifier of the node is the name identifier corresponding to the array node, then it can be determined that the node is an array node, and each pair of start name identifiers in the node <searchmatchitem>and the end name identifier< / searchmatchitem> The amount of data included between the two nodes is used as the amount of data of each child node in the array node. Next, the browser may execute step S608.
[0343] S606, parsing the data and displaying the parsed data;
[0344] If the response message is not truncated, the browser can parse the data returned by the cloud service and display the parsed data, thus ending the process.
[0345] S607, calculating the data volume of each child node in the JSON format array node;
[0346] The browser may traverse each node in the response message in order, and upon traversing to a node, determine whether the name identifier of the node is the name identifier searchMatchItem corresponding to the array node. If the name identifier of the node is the name identifier searchMatchItem corresponding to the array node, determine that the node is an array node, and use the data volume of the child node where the name identifier searchMatchItem corresponding to each child node in the node is located as the data volume of each child node in the array node. Next, the browser may execute step S608.
[0347] S608, calculating the target number of entries, and requesting data again according to the target number of entries.
[0348] After determining the amount of data for each child node in the array node, the browser can calculate the difference between the maximum amount of data that the cloud service can transmit at one time and the amount of data of non-array nodes included in the response message, and then calculate the difference between the difference and the reserved data amount to obtain the amount of data of the array nodes included in the response message that the cloud service can transmit at one time.
[0349] Next, the browser can determine the maximum amount of data from the amount of data of each child node in the array node, and then calculate the quotient between the amount of data of the array node and the maximum amount of data to obtain the target number of items. The browser can then request data from the cloud service again according to the target number of items, and return to step S601.
[0350] In the technical solution of this application, the operations involved in obtaining, storing, using, processing, transmitting, providing and disclosing user personal information are all carried out with the user's authorization.
[0351] Corresponding to the above data acquisition method, the embodiment of the present application further provides a data acquisition device. The following is an introduction to a data acquisition device provided by the embodiment of the present application.
[0352] like Figure 7 As shown, a data acquisition device is applied to a browser, the browser sends a request message to a terminal device through a cloud service, the terminal device responds to the request message, and returns a response message to the browser through the cloud service, the device includes:
[0353] A response message acquisition module 701 is used to acquire the response message forwarded by the cloud service;
[0354] A response message determination module 702, configured to determine whether the response message is truncated by using a data integrity determination method corresponding to the data format of the response message;
[0355] A target number determination module 703 is used to determine, if the response message is truncated, the target number of data included in the response message of the data format that can be transmitted by the cloud service at a single time according to the maximum amount of data that can be transmitted by the cloud service at a single time and the data format of the response message;
[0356] The data request module 704 is used to request data from the cloud service according to the target number of items, so that the cloud service returns data to the browser according to the target number of items.
[0357] It can be seen that in the implementation of this application, the browser can obtain the response message forwarded by the cloud service; determine whether the response message is truncated through the data integrity determination method corresponding to the data format of the response message; if the response message is truncated, determine the target number of data included in the response message of the data format that the cloud service can transmit at a time according to the maximum amount of data that the cloud service can transmit at a time and the data format of the response message; according to the target number of data, request data from the cloud service so that the cloud service returns data to the browser according to the target number of data. In the case where the response message is truncated by the cloud service, the browser can determine the target number of data included in the response message of the data format that the cloud service can transmit at a time according to the maximum amount of data that the cloud service can transmit at a time and the data format of the response message. The response message includes array nodes and non-array nodes. Since the data format of the response message can reflect the amount of data occupied by array nodes and non-array nodes in the response message of the data format, the target number of data that the cloud service can transmit at a time can be determined based on the maximum amount of data that the cloud service can transmit at a time and the data format of the response message, and the data is the sub-nodes included in the array node. Next, the browser can request data from the cloud service according to the target number of entries, and the cloud service can return data to the browser according to the target number of entries. Since the amount of data in the target number of entries can meet the maximum amount of data that the cloud service can transmit at a time, it can be guaranteed that the data in the response message returned by the cloud service is not truncated, thereby avoiding errors when the browser parses the data and avoiding abnormal interface display due to the browser's inability to obtain complete data.
[0358] As an implementation of an embodiment of the present application, the above-mentioned response message may include multiple array nodes and non-array nodes, and the array node may include multiple child nodes. In this case, the above-mentioned target number determination module 703 may include:
[0359] A data volume determination submodule, configured to determine the amount of data of array nodes included in the response message that the cloud service can transmit at a single time, based on the maximum amount of data that the cloud service can transmit at a single time and the amount of data of non-array nodes included in the response message;
[0360] A maximum value determination submodule, used to count the amount of data of each sub-node in the array node included in the response message, and determine the maximum value from the data amount;
[0361] The target number calculation submodule is used to calculate the quotient between the amount of data of the array nodes included in the response message that the cloud service can transmit at one time and the maximum value, and obtain the target number of data included in the response message of this data format that the cloud service can transmit at one time.
[0362] As an implementation of an embodiment of the present application, the above-mentioned data volume determination submodule may include:
[0363] A difference calculation unit, used to calculate the difference between the maximum amount of data that can be transmitted by the cloud service at a single time and the amount of data of the non-array node;
[0364] The data volume calculation unit is used to calculate the difference between the difference and the preset reserved data volume, and obtain the data volume of the array nodes included in the response message that can be transmitted by the cloud service at a single time.
[0365] As an implementation of the embodiment of the present application, the above-mentioned maximum value determination submodule may include:
[0366] A first data volume determination unit is used for, if the response message is in XML format, sequentially traversing each node in the response message, and for each traversed node, determining whether the name identifier of the node is the name identifier corresponding to the array node; if the name identifier of the node is the name identifier corresponding to the array node, determining that the node is an array node, and taking the data volume of the data included between each pair of the start name identifier and the end name identifier in the node as the data volume of each child node;
[0367] The second data volume determination unit is used to traverse each node in the response message in order if the response message is in JSON format, and determine whether the name identifier of each node is the name identifier corresponding to the array node each time the node is traversed; if the name identifier of the node is the name identifier corresponding to the array node, determine that the node is an array node, and use the data volume of the child node where the name identifier corresponding to each child node in the node is located as the data volume of each child node.
[0368] As an implementation of the embodiment of the present application, the above-mentioned response message determination module 702 may include:
[0369] A first response message determination submodule, for traversing each field included in the response message if the response message is in XML format, and determining whether the response message includes a message end tag; if the response message does not include a message end tag, determining that the response message is truncated;
[0370] A second response message determination submodule is used to, if the response message is in XML format, call a data integrity determination function corresponding to the XML format, parse the response message, and obtain a parsing result; if there is a node indicating a parsing error in the parsing result, determine that the response message is truncated;
[0371] The third response message determination submodule is used to call the data integrity determination function corresponding to the JSON format to parse the response message if the response message is in the JSON format; if the data integrity determination function corresponding to the JSON format reports an error, it is determined that the response message is truncated.
[0372] As an implementation method of the embodiment of the present application, the terminal where the above-mentioned browser is located may be deployed with a local service, and the cloud service may be deployed with a transparent transmission service. In this case, the above-mentioned response message acquisition module 701 may include:
[0373] A first response message acquisition submodule, used for the browser to acquire a response message forwarded by the cloud service, wherein the request message is sent by the browser to the cloud service and sent by the transparent transmission service to the terminal device;
[0374] A second response message acquisition submodule, used for the local service to acquire a response message forwarded by the cloud service, wherein the request message is sent by the local service to the cloud service and sent by the transparent transmission service to the terminal device;
[0375] The third response message acquisition submodule is used for the browser to obtain a response message sent by the cloud service, wherein the response message is obtained by parsing the response data sent by the cloud service to the transparent transmission service from the terminal device, and the request message is sent by the browser to the cloud service and sent by the transparent transmission service to the terminal device.
[0376] As an implementation manner of the embodiment of the present application, the above-mentioned browser may include a web page. In this case, the above-mentioned device may also include:
[0377] The data display module is used to parse the data returned to the browser after acquiring the data returned by the cloud service to the browser according to the target number of items, and display the parsed data in the web page.
[0378] Corresponding to the above data acquisition method, the embodiment of the present application further provides a data acquisition system. The following is an introduction to a data acquisition system provided by the embodiment of the present application.
[0379] like Figure 8 As shown, a data acquisition system includes a browser 801, a cloud service 802 and a terminal device 803, wherein:
[0380] The browser 801 is used to send a request message to the terminal device 803 through the cloud service 802,
[0381] The terminal device 803 is used to respond to the request message and return a response message to the browser 801 through the cloud service 802;
[0382] The cloud service 802 is further used to forward the response message to the browser 801;
[0383] The browser 801 is also used to execute the data acquisition method described in any of the above embodiments.
[0384] It can be seen that in the implementation of this application, the browser can obtain the response message forwarded by the cloud service; determine whether the response message is truncated through the data integrity determination method corresponding to the data format of the response message; if the response message is truncated, determine the target number of data included in the response message of the data format that the cloud service can transmit at a time according to the maximum amount of data that the cloud service can transmit at a time and the data format of the response message; according to the target number of data, request data from the cloud service so that the cloud service returns data to the browser according to the target number of data. In the case where the response message is truncated by the cloud service, the browser can determine the target number of data included in the response message of the data format that the cloud service can transmit at a time according to the maximum amount of data that the cloud service can transmit at a time and the data format of the response message. The response message includes array nodes and non-array nodes. Since the data format of the response message can reflect the amount of data occupied by array nodes and non-array nodes in the response message of the data format, the target number of data that the cloud service can transmit at a time can be determined based on the maximum amount of data that the cloud service can transmit at a time and the data format of the response message, and the data is the sub-nodes included in the array node. Next, the browser can request data from the cloud service according to the target number of entries, and the cloud service can return data to the browser according to the target number of entries. Since the amount of data in the target number of entries can meet the maximum amount of data that the cloud service can transmit at a time, it can be guaranteed that the data in the response message returned by the cloud service is not truncated, thereby avoiding errors when the browser parses the data and avoiding abnormal interface display due to the browser's inability to obtain complete data.
[0385] The present application also provides a browser, such as Figure 9 As shown, including:
[0386] Memory 901, used for storing computer programs;
[0387] The processor 902 is used to implement the data acquisition method described in any of the above embodiments when executing the program stored in the memory 901.
[0388] In addition, the above-mentioned browser may further include a communication bus and / or a communication interface, and the processor 902, the communication interface, and the memory 901 communicate with each other via the communication bus.
[0389] It can be seen that in the embodiment of the present application, the browser can obtain the response message forwarded by the cloud service; determine whether the response message is truncated by the data integrity determination method corresponding to the data format of the response message; if the response message is truncated, determine the target number of data included in the response message of the data format that the cloud service can transmit at a time according to the maximum amount of data that the cloud service can transmit at a time and the data format of the response message; according to the target number of data, request data from the cloud service so that the cloud service returns data to the browser according to the target number of data. In the case where the response message is truncated by the cloud service, the browser can determine the target number of data included in the response message of the data format that the cloud service can transmit at a time according to the maximum amount of data that the cloud service can transmit at a time and the data format of the response message. The response message includes array nodes and non-array nodes. Since the data format of the response message can reflect the amount of data occupied by array nodes and non-array nodes in the response message of the data format, based on the maximum amount of data that the cloud service can transmit at a time and the data format of the response message, the target number of data that the cloud service can transmit at a time can be determined, and the data is the sub-nodes included in the array node. Next, the browser can request data from the cloud service according to the target number of entries, and the cloud service can return data to the browser according to the target number of entries. Since the amount of data in the target number of entries can meet the maximum amount of data that the cloud service can transmit at a time, it can be guaranteed that the data in the response message returned by the cloud service is not truncated, thereby avoiding errors when the browser parses the data and avoiding abnormal interface display due to the browser's inability to obtain complete data.
[0390] The communication bus mentioned in the above browser can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0391] The communication interface is used for communication between the above browser and other devices.
[0392] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0393] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0394] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned data acquisition methods are implemented.
[0395] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any of the data acquisition methods in the above embodiments.
[0396] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a solid-state hard disk (SSD), etc.
[0397] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0398] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, system, browser, computer-readable storage medium, and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0399] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. A data acquisition method, characterized in that: Applied to a browser, the browser sends a request message to a terminal device through a cloud service, the terminal device responds to the request message, and returns a response message to the browser through the cloud service, the method comprising: Obtaining a response message forwarded by the cloud service; Determining whether the response message is truncated by using a data integrity determination method corresponding to the data format of the response message; If the response message is truncated, determine the target number of data items included in the response message of the data format that can be transmitted by the cloud service at a single time according to the maximum amount of data that can be transmitted by the cloud service at a single time and the data format of the response message; According to the target number of items, data is requested from the cloud service, so that the cloud service returns data to the browser according to the target number of items.
2. The method according to claim 1, characterized in that: The response message includes an array node and a non-array node, and the array node includes a plurality of child nodes; The step of determining, based on the maximum amount of data that can be transmitted by the cloud service at a single time and the data format of the response message, a target number of data items included in the response message of the data format that can be transmitted by the cloud service at a single time comprises: Determine the amount of data of array nodes included in the response message that can be transmitted by the cloud service at a single time according to the maximum amount of data that can be transmitted by the cloud service at a single time and the amount of data of non-array nodes included in the response message; Counting the amount of data of each sub-node in the array node included in the response message, and determining a maximum value from the amount of data; The quotient between the amount of data of the array nodes included in the response message that the cloud service can transmit at one time and the maximum value is calculated to obtain the target number of data items included in the response message of the data format that the cloud service can transmit at one time.
3. The method according to claim 2, characterized in that The step of determining the amount of data of the array nodes included in the response message that can be transmitted by the cloud service at a single time according to the maximum amount of data that can be transmitted by the cloud service at a single time and the amount of data of the non-array nodes included in the response message, comprises: Calculate the difference between the maximum amount of data that can be transmitted by the cloud service at one time and the amount of data of the non-array node; The difference between the difference and the preset reserved data volume is calculated to obtain the data volume of the array nodes included in the response message that can be transmitted by the cloud service at a single time.
4. The method according to claim 2, characterized in that: The step of counting the amount of data of each sub-node in the array node included in the response message includes at least one of the following: If the response message is in XML format, traverse each node in the response message in order, and for each node traversed, determine whether the name identifier of the node is the name identifier corresponding to the array node; If the name identifier of the node is the name identifier corresponding to the array node, the node is determined to be an array node, and the amount of data included between each pair of the start name identifier and the end name identifier in the node is used as the amount of data of each child node; If the response message is in JSON format, traverse each node in the response message in order, and for each node traversed, determine whether the name identifier of the node is the name identifier corresponding to the array node; If the name identifier of the node is the name identifier corresponding to the array node, the node is determined to be an array node, and the data volume of the child node where the name identifier corresponding to each child node in the node is located is used as the data volume of each child node.
5. The method according to any one of claims 1 to 4, characterized in that: The step of determining whether the response message is truncated by using a data integrity determination method corresponding to the data format of the response message comprises at least one of the following: If the response message is in XML format, traverse the fields included in the response message to determine whether the response message includes a message end tag; if the response message does not include a message end tag, determine that the response message is truncated; If the response message is in XML format, calling a data integrity determination function corresponding to the XML format, parsing the response message to obtain a parsing result; if there is a node indicating a parsing error in the parsing result, determining that the response message is truncated; If the response message is in JSON format, call the data integrity determination function corresponding to the JSON format to parse the response message; if the data integrity determination function corresponding to the JSON format reports an error, it is determined that the response message is truncated.
6. The method according to any one of claims 1 to 4, characterized in that: The terminal where the browser is located is deployed with a local service, and the cloud service is deployed with a transparent transmission service; The step of obtaining the response message forwarded by the cloud service includes at least one of the following: The browser obtains a response message forwarded by the cloud service, wherein the request message is sent by the browser to the cloud service and sent by the transparent transmission service to the terminal device; The local service obtains a response message forwarded by the cloud service, wherein the request message is sent by the local service to the cloud service and sent by the transparent transmission service to the terminal device; The browser obtains a response message sent by the cloud service, wherein the response message is obtained by parsing the response data sent by the cloud service to the transparent transmission service from the terminal device, and the request message is sent by the browser to the cloud service and sent by the transparent transmission service to the terminal device.
7. The method according to any one of claims 1 to 4, characterized in that: The browser includes a web page; The method further comprises: After acquiring the data returned by the cloud service to the browser according to the target number of items, the data returned to the browser is parsed, and the parsed data is displayed on the web page.
8. A data acquisition device, characterized in that: Applied to a browser, the browser sends a request message to a terminal device through a cloud service, the terminal device responds to the request message, and returns a response message to the browser through the cloud service, the device includes: A response message acquisition module, used to acquire the response message forwarded by the cloud service; A response message determination module, used to determine whether the response message is truncated by using a data integrity determination method corresponding to the data format of the response message; a target number determination module, configured to determine, if the response message is truncated, a target number of data items included in the response message of the data format that can be transmitted by the cloud service at a single time, based on the maximum amount of data that can be transmitted by the cloud service at a single time and the data format of the response message; The data request module is used to request data from the cloud service according to the target number of items, so that the cloud service returns data to the browser according to the target number of items.
9. The device according to claim 8, characterized in that The response message includes an array node and a non-array node, and the array node includes a plurality of child nodes; The target number determination module includes: A data volume determination submodule, configured to determine the amount of data of array nodes included in the response message that the cloud service can transmit at a single time, based on the maximum amount of data that the cloud service can transmit at a single time and the amount of data of non-array nodes included in the response message; A maximum value determination submodule, used to count the amount of data of each sub-node in the array node included in the response message, and determine the maximum value from the data amount; A target number calculation submodule is used to calculate the quotient between the amount of data of the array nodes included in the response message that can be transmitted by the cloud service at a single time and the maximum value, so as to obtain the target number of data included in the response message of the data format that can be transmitted by the cloud service at a single time; The data volume determination submodule includes: A difference calculation unit, used to calculate the difference between the maximum amount of data that can be transmitted by the cloud service at a single time and the amount of data of the non-array node; A data volume calculation unit, used to calculate the difference between the difference and a preset reserved data volume, and obtain the data volume of the array nodes included in the response message that can be transmitted by the cloud service at a single time; The maximum value determination submodule includes: A first data volume determination unit is used for, if the response message is in XML format, sequentially traversing each node in the response message, and for each traversed node, determining whether the name identifier of the node is the name identifier corresponding to the array node; if the name identifier of the node is the name identifier corresponding to the array node, determining that the node is an array node, and taking the data volume of the data included between each pair of the start name identifier and the end name identifier in the node as the data volume of each child node; A second data volume determination unit is used for, if the response message is in JSON format, sequentially traversing each node in the response message, and for each traversal to a node, determining whether the name identifier of the node is the name identifier corresponding to the array node; if the name identifier of the node is the name identifier corresponding to the array node, determining that the node is an array node, and taking the data volume of the child node where the name identifier corresponding to each child node in the node is located as the data volume of each child node; The response message determination module includes: A first response message determination submodule, for traversing each field included in the response message if the response message is in XML format, and determining whether the response message includes a message end tag; if the response message does not include a message end tag, determining that the response message is truncated; A second response message determination submodule is used to, if the response message is in XML format, call a data integrity determination function corresponding to the XML format, parse the response message, and obtain a parsing result; if there is a node indicating a parsing error in the parsing result, determine that the response message is truncated; A third response message determination submodule is used to, if the response message is in JSON format, call a data integrity determination function corresponding to the JSON format to parse the response message; if the data integrity determination function corresponding to the JSON format reports an error, determine that the response message is truncated; The terminal where the browser is located is deployed with a local service, and the cloud service is deployed with a transparent transmission service; The response message acquisition module includes: A first response message acquisition submodule, used for the browser to acquire a response message forwarded by the cloud service, wherein the request message is sent by the browser to the cloud service and sent by the transparent transmission service to the terminal device; A second response message acquisition submodule, used for the local service to acquire a response message forwarded by the cloud service, wherein the request message is sent by the local service to the cloud service and sent by the transparent transmission service to the terminal device; A third response message acquisition submodule is used for the browser to acquire a response message sent by the cloud service, wherein the response message is obtained by parsing the response data sent by the cloud service to the transparent transmission service from the terminal device, and the request message is sent by the browser to the cloud service and sent by the transparent transmission service to the terminal device; The browser includes a web page; The device also includes: The data display module is used to parse the data returned to the browser after acquiring the data returned by the cloud service to the browser according to the target number of items, and display the parsed data in the web page.
10. A data acquisition system, characterized in that: The data acquisition system includes a browser, a cloud service and a terminal device, wherein: The browser is used to send a request message to the terminal device through the cloud service, The terminal device is used to respond to the request message and return a response message to the browser through the cloud service; The cloud service is further used to forward the response message to the browser; The browser is also used to execute the method described in any one of claims 1-7.
11. A browser, characterized in that: include: Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-7 when executing a program stored in a memory.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.