Method and device for modifying data of software object, equipment and medium
By analyzing the target instructions and finding and modifying data in the software object according to the access path, the problem of lack of efficient dynamic modification methods in the existing technology is solved, and the precise modification of software object data and the improvement of operational performance is achieved.
Patent Information
- Application Number
- CN202311198771.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-15
- Publication Date
- 2025-03-18
AI Technical Summary
The prior art lacks methods for efficient dynamic modification of software objects, especially when some of the data of the software objects need to be accurately modified.
By receiving and parsing the target instructions to modify the target object, determine the operation type and access path, find and modify the target data from the target object according to the operation type.
It realizes dynamic modification of some data in software objects, improves the operating performance of software applications, and provides a general object data modification scheme that covers different operation types and is aimed at different data types.
Smart Images

Figure CN119645477A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of computer technology, and in particular, to a method, apparatus, device, and medium for modifying data of a software object. Background Art
[0002] In the operation of some software applications, it is desirable to dynamically modify software objects. For example, a client application obtains prediction data in advance and loads an object according to the prediction data, and then obtains update data for the prediction data based on real data, so it is desirable to modify the loaded object of the client according to the update data. However, in some scenarios, there is a lack of efficient methods for dynamically modifying software objects in the prior art.
[0003] Therefore, a new method for modifying the data of a software object is needed. Summary of the invention
[0004] The embodiments of the present disclosure describe a method, apparatus, device, and medium for modifying data of a software object.
[0005] According to a first aspect, there is provided a method for modifying data of a software object, comprising:
[0006] Receiving a target instruction for modifying a target object, parsing the target instruction, and determining at least an operation type of the target instruction and an access path from the target object to target data contained in the target object;
[0007] The target data is searched from the target object according to the access path, and if the search is successful, the target data is modified at least according to the operation type.
[0008] According to a second aspect, there is provided an apparatus for modifying data of a software object, comprising:
[0009] a parsing unit configured to receive a target instruction for modifying a target object, parse the target instruction, and determine at least an operation type of the target instruction and an access path from the target object to target data contained in the target object;
[0010] The modification unit is configured to search for the target data from the target object according to the access path, and if the search is successful, modify the target data at least according to the operation type.
[0011] According to a third aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to execute the method described in the first aspect.
[0012] According to a fourth aspect, an electronic device is provided, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method described in the first aspect is implemented.
[0013] According to an embodiment of the present disclosure, a method, device, equipment and medium for modifying the data of a software object are provided. A target instruction for modifying a target object can be received, and the target instruction can be parsed to at least determine the operation type of the target instruction and the access path from the target object to the target data contained in the target object. Then, according to the access path, the target data is searched from the target object, and if the search is successful, the target data is modified at least according to the operation type. By using any one of the above methods, devices, storage media and electronic devices, the data contained in the software object can be efficiently modified to improve the running performance of the software application. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 A schematic diagram showing the structure of an object;
[0015] Figure 2 A schematic flow chart of a method for modifying data of a software object according to an embodiment of the present disclosure is shown;
[0016] Figure 3 A schematic diagram showing a target instruction according to an embodiment of the present disclosure is shown;
[0017] Figure 4 A schematic diagram showing an access path of target data according to an embodiment of the present disclosure;
[0018] Figure 5 A schematic diagram showing operation categories according to an embodiment of the present disclosure;
[0019] Figure 6 A schematic diagram of nested instructions according to an embodiment of the present disclosure is shown;
[0020] Figure 7 A schematic diagram showing acquisition of target data by reflection according to an embodiment of the present disclosure is shown;
[0021] Figure 8 A schematic block diagram of a device for modifying data of a software object according to an embodiment of the present disclosure is shown;
[0022] Fig. 9 A schematic diagram of the structure of an electronic device suitable for implementing an embodiment of the present disclosure is shown;
[0023] Fig.10 A schematic diagram of the structure of a storage medium suitable for implementing the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0024] The technical solution provided in this specification is further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant inventions, rather than to limit the inventions. It should also be noted that, for ease of description, only the parts related to the relevant inventions are shown in the accompanying drawings. It should be noted that, in the absence of conflict, the embodiments of the present disclosure and the features in the embodiments can be combined with each other.
[0025] In the description of the implementations of the present disclosure, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one / kind of implementation" or "the implementation" should be understood as "at least one / kind of implementation". The term "some implementations" should be understood as "at least some implementations". Other explicit and implicit definitions may also be included below.
[0026] As mentioned above, in some software application scenarios, it is hoped that software objects can be modified dynamically. For example, a client application first obtains prediction data and loads an object based on the prediction data, and then obtains update data for the prediction data based on real data, so it is hoped that the pre-loaded object can be modified according to the update data. However, in actual operation scenarios, the modification of existing objects often modifies part of the object's data, and existing objects usually form a tree-structured inclusion relationship with the data they contain (for example, object types or basic types of data). The prior art lacks an efficient method for accurately modifying part of the data they contain. For example, Figure 1 A schematic diagram of the object structure is shown. Figure 1 As shown, for example, the target object is a datalist object, and the datalist object is an array object, which includes multiple array members, such as datalist[0], datalist[1]...datalist[n]. Each array itself is also an object and can include its own properties. For example, datalist[0] can include its properties user and viewmore. The property user itself can also be an object, and the object can include its property username, for example. For example, when the target data to be modified is the property username, the prior art lacks an efficient method for accurately modifying the property.
[0027] In order to solve the above technical problems, the embodiment of the present disclosure provides a method for modifying the data of a software object. In some embodiments, a target instruction for modifying a target object can be received, and the target instruction can be parsed, for example, to determine the operation type of the target instruction, the access path from the target object to the target data contained in the target object, and the target value. Then, according to the parsed access path, the target data is searched from the target object, and if the search is successful, the target data of the target object is modified at least according to the operation type and the target value of the target instruction. The advantage of this method is that: on the one hand, the dynamic modification of part of the data in the object can be realized by this method. Specifically, the target instruction can include the access path of the data to be modified, so that the receiver of the target instruction can obtain the location (access path) of the target data in the modified target object by parsing the target instruction, and then the target data can be accurately found from the target object according to the access path and modified. On the other hand, the target instruction can also include different operation types, so that multiple different operation types can be obtained by parsing the target instruction, and then different modification operations can be implemented on the target data according to different operation types. In different embodiments, the operation on the target data can also be optimized according to the different data types of the target data. Thus, a universal modification scheme for object data of different types covering different operation types and for different data types is provided. Thirdly, in some embodiments, when the target data is found, the access path and the modified target data can be associated and saved in a predetermined cache, so that when the target data of the same access path is accessed subsequently, it can be directly extracted from the cache, further improving the overall modification efficiency of the object data.
[0028] The detailed process of this method is further described below.
[0029] Figure 2 FIG. 1 is a flow chart showing a method for modifying data of a software object according to an embodiment of the present disclosure. Figure 2 As shown, the method comprises at least the following steps:
[0030] Step S201, receiving a target instruction for modifying a target object, parsing the target instruction, and determining at least an operation type of the target instruction and an access path from the target object to target data contained in the target object;
[0031] Step S203: searching the target data from the target object according to the access path, and if the search is successful, modifying the target data at least according to the operation type.
[0032] First, in step S201, a target instruction for modifying a target object is received, and the target instruction is parsed to at least determine an operation type of the target instruction and an access path from the target object to target data contained in the target object.
[0033] An object can usually be used as a basic unit of a program. An object can contain data and functions that operate on the data. In different embodiments, the target object can be an object of different specific types, which is not limited in this specification. In one embodiment, for example, it can be a model object, which can be used to store data, so that, for example, an interface can be rendered through the data stored in the model object.
[0034] In this step, the receiver of the target instruction receives the modification instruction (target instruction) for the target object sent by the instruction sender. By parsing the target instruction, at least the operation type of the target instruction and the access path from the target object to the target data contained in the target object are determined. In different embodiments, the specific receiver and sender of the target instruction may be different. In one embodiment, the receiver of the target instruction may be, for example, a client application on a user terminal, and the sender may be a server that determines the update data. The server may, for example, send the modification instruction for the target object to the client application after determining the update data. In different embodiments, the user terminal may be different types of computer devices, which is not limited in this specification. In one embodiment, for example, it may be a mobile terminal, and specifically, for example, it may be one of a mobile phone, a notebook, a tablet computer, and a car computer.
[0035] The target instruction may include the modified operation type and the access path of the target data. In one embodiment, according to the specific operation type, the target instruction may also include the modified target value. Figure 3 FIG. 1 shows a schematic diagram of a target instruction according to an embodiment of the present disclosure. Figure 3 As shown, the target instruction may include, for example, an operation type ("op"), an access path ("path") of target data, and a target value ("value").
[0036] The access path of the target data, that is, the access path from the target object to the target data contained in the target object, can be used to determine the specific location of the target data in the target object. In different embodiments, the access path can have different construction methods. In one embodiment, the access path includes a plurality of fields in sequence, the first field of the plurality of fields corresponds to the target object, the last field of the plurality of fields corresponds to the target data, and the other fields of the plurality of fields correspond to the intermediate objects between the target object and the target data, and the intermediate objects include a single object or an array object, wherein the post-placed fields of the corresponding fields of any array object correspond to the array members of the array object. In different embodiments, the various fields shown can be divided, for example, by predetermined symbols. In different specific embodiments, the predetermined symbols can be different. In a specific embodiment, for example, they can be divided by the symbol " / ". Figure 4 FIG. 1 is a schematic diagram showing an access path of target data according to an embodiment of the present disclosure. Figure 4 In the example shown, the access path of the target data may be " / data / 0 / user_list / 0 / userinfo / username", which includes a plurality of fields separated by " / ": "data", "0", "user_list", "0", "userinfo", "username". "data" represents the target object, which may be, for example, a datalist object. Datalist is an array object that may include different array members. The combination of the "data" field and the subsequent "0" field may represent the member object of the datalist object with the subscript 0, which may be identified as datalist[0]. "user_list" may represent the attribute of the datalist[0] object, which itself may be a userlist object. The combination of the "user_list" field and the subsequent "0" field may represent the member object of the userlist object with the subscript 0, which may be represented as userlist[0]. The userlist[0] object has the attribute "userinfo", which is also an object, and has the attribute "username". "Username" is, for example, an attribute of a basic type (e.g., a numeric type, a Boolean type, or a string type). It can be seen that the access path may represent the position of the target data in the target object.
[0037] In different embodiments, the types of operations included in the target instruction may be different. Figure 5 FIG. 2 shows a schematic diagram of operation categories according to an embodiment of the present disclosure. Figure 5As shown, in one embodiment, the operation type may include a replace operation for changing the value of the target data. The target instruction may be parsed to determine the operation type of the target instruction, the access path from the target object to the target data of the target object, and the target value. In another embodiment, the operation type may include an add operation for adding an array member or attribute included in the target data. Thus, the target instruction may be parsed to determine the operation type of the target instruction, the access path from the target object to the target data of the target object, and the target value. In another embodiment, the operation type may also include reorder data for reordering the array members included in the target data. The target instruction may be parsed to determine the operation type of the target instruction, the access path from the target object to the target data of the target object, and the target value. In another embodiment, the operation type may also include reorder data for reordering the array members included in the target data. The target instruction may be parsed to determine the operation type of the target instruction, the access path from the target object to the target data of the target object, and the target value. In another embodiment, the operation type may also include a remove operation for setting the value of the target data to a default value. Through the above manner, a universal modification solution for object data covering different operation types and targeting different data types may be provided.
[0038] In one embodiment, the operation type may further include a nested operation. Specifically, if the operation type is a nested operation, the target value may include one or more sub-instructions, and the operation type of each sub-instruction may include one of an add operation, a delete operation, a replace operation, a reorder operation, and a nested operation. Each sub-instruction may be further parsed from the target value. Figure 6 FIG. 2 shows a schematic diagram of nested instructions according to an embodiment of the present disclosure. Figure 6 In the example shown, a plurality of sub-instructions may be included in the nested operation. In the above manner, in the subsequent steps, multiple operations may be implemented for target data of, for example, a specific type according to each sub-instruction. In different specific embodiments, the specific types targeted by the nested operation may be different. In a specific embodiment, in the subsequent steps, for example, multiple operations may be implemented for the target data of the Json object type according to the nested operation.
[0039] Then, in step S303, the target data is searched from the target object according to the access path, and if the search is successful, the target data is modified at least according to the operation type.
[0040] To search for target data in the target object, the attributes included in the target object can be reflected layer by layer according to the access path. In one embodiment, the multiple fields can be parsed out in sequence from the access path, wherein for each field before the last field, if the field corresponds to a single object, the single object corresponding to the field is obtained by reflection, and the attributes corresponding to the post-field of the field are searched from the attributes included in the single object corresponding to the field; if the field corresponds to an array object, the array member corresponding to the post-field of the field is obtained by reflection according to the subscript of the field and the array member corresponding to the post-field of the field, and the attributes corresponding to the post-field of the field are searched from the attributes included in the array member. Figure 7 A schematic diagram of obtaining target data through reflection according to an embodiment of the present disclosure is shown. For example, the object datalist[0] can be obtained by reflection according to the fields "data" and "0", and "user_list" can be found from the properties of the object datalist[0]. Then, the object userlist[0] can be obtained by reflection according to "user_list" and "0", and "userinfo" can be found from the properties of userlist[0]. Then, the object userinfo can be obtained by reflection, and "username" can be found from its properties. In one embodiment, after the target data is found, the target data can be modified through the parent object of the target data. For example, Figure 7 In the example shown, the attribute username can be modified through the above-mentioned object userinfo. In one embodiment, for example Figure 7 In the sequential searches by field order shown, if any one of the attribute or array member searches by field fails, the search failure for the target data can be exited and the search for the target data is determined to be unsuccessful. In one embodiment, if the search for the target data is determined to be unsuccessful, the modification of the target data can be abandoned.
[0041] As mentioned above, in different embodiments, the operation type of the target instruction may be different. In one embodiment, if the operation type is a replacement operation, the value of the target data may be changed according to the target value. In a specific embodiment, if the data type of the target data is a basic type, the data type of the target value may be converted to the basic type, and the value of the target data may be changed according to the converted target value. In another embodiment, if the data type of the target data is an object type, deserialization may be performed according to the target value to obtain an instance of the object type, and the instance may be assigned to the target data. In one embodiment, if the operation type is an addition operation, the array member or attribute included in the target data is added according to the target value. In one embodiment, if the operation type is a deletion operation, the value of the target data is set to a default value. In one embodiment, if the operation type is a reordering operation, the array members included in the target data are reordered according to the target value. In one embodiment, if the operation type is a nested operation, multiple operations may be performed on target data of a specific type, for example, according to each sub-instruction included in the target value. In the above manner, different operation types may be modified for object data of different data types.
[0042] In one embodiment, if the search is successful, the access path and the modified target data can also be associated and saved in a predetermined cache. In a specific embodiment, in order to prevent different object classes from having attributes with duplicate names, the characteristic that the same object cannot have attributes with the same name can be used to prevent the confusion of attributes with duplicate names in the buffer. Therefore, if the data type of the target data is an object, the access path, the parent object of the target data, and the modified target data are associated and saved in the cache. Since for attributes of basic types, there is no problem that different object classes have attributes with duplicate names. Therefore, in another specific embodiment, if the data type of the target data is a basic type, the access path, the modified target data, and the class name to which the target data is a subordinate attribute can be associated and saved in the cache. In the above manner, the mapping relationship between the most recently accessed (accessed for modifying data) access path and the target data can be saved in the cache, so that when the target data of the same access path is accessed again, it can be modified according to the target data extracted from the cache without having to reflect layer by layer based on the access path to find the target data again. Moreover, since the most recently accessed data has a high probability of being accessed again in the subsequent operation of the application, the time consumed in modifying the object data is greatly reduced.
[0043] In order to further improve the efficiency of modifying object data. In one embodiment, the target object can be a pre-built global singleton object. In the actual operating environment of the application, the scenario of modifying data is often not the first scenario to load the target object, but the existing scheme for modifying the target object usually constructs the target object used in the scenario of modifying data separately. For example, in an application, the scenario of modifying object data is, for example, a search scenario, and the scene before the search scenario is, for example, a recommended content scenario, and the target object used in the recommended content scenario is also constructed. Therefore, the target object constructed by the recommended content scenario can be set as a global singleton object, for example. A global singleton object means that an object of this type has only one object instance in the global scope and can be accessed in the global scope. Then, the global singleton object can be used in the scenario of modifying object data to reduce the time cost of constructing objects in the scenario of modifying object data and improve the execution efficiency of the application.
[0044] Figure 8 A schematic block diagram of a bytecode modification device according to an embodiment of the present disclosure is shown. The device is used to perform the following steps: Figure 2 The method shown, such as Figure 8 As shown, the device 800 includes:
[0045] The parsing unit 801 is configured to receive a target instruction for modifying a target object, parse the target instruction, and determine at least an operation type of the target instruction and an access path from the target object to target data contained in the target object;
[0046] The modification unit 802 is configured to search for the target data from the target object according to the access path, and if the search is successful, modify the target data at least according to the operation type.
[0047] The present disclosure also provides an electronic device, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the following is achieved: Figure 2 The method shown.
[0048] You can also refer to the following Fig. 9 , which shows a structural schematic diagram of an electronic device 800 suitable for implementing an embodiment of the present application. Fig. 9 The electronic device 900 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0049] like Fig. 9As shown, the electronic device 900 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 901. The above-mentioned processing device 901 may be a general-purpose processor, a digital signal processor (Digital Signal Processing, DSP), a microprocessor or a microcontroller, and may further include an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 902 or the program loaded from the storage device 908 to the random access memory (RAM) 903. In RAM903, various programs and data required for the operation of the electronic device 900 are also stored. The processing device 901, ROM902 and RAM903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0050] Typically, the following devices may be connected to the I / O interface 905: an input device 906 including, for example, a touch screen, a touch pad, a keyboard, a mouse, etc.; an output device 907 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 908 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 909. The communication device 909 may allow the electronic device 900 to communicate with other devices wirelessly or by wire to exchange data. Fig. 9 The electronic device 900 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Fig. 9 Each block shown in the figure may represent one device, or may represent multiple devices as required.
[0051] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 909, or installed from the storage device 908, or installed from the ROM 902. When the computer program is executed by the processing device 901, the above-mentioned functions defined in the method for modifying the data of the software object provided in the embodiment of the present application are executed.
[0052] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed in a computer, the computer is caused to execute the following steps provided in the present disclosure: Figure 2 A method for modifying the data of a software object as shown in . Fig.10 A schematic diagram of a storage medium for implementing an embodiment of the present application. Fig.10 As shown, the storage medium 1000 may be a non-transitory computer-readable storage medium for storing non-transitory computer-executable instructions 1001. When the non-transitory computer-executable instructions 1001 are executed by the processor, the method for modifying the data of a software object provided in the embodiment of the present application may be implemented. For example, when the non-transitory computer-executable instructions 1001 are executed by the processor, one or more steps in the method for modifying the data of a software object provided in the embodiment of the present application may be executed. For example, the storage medium 1000 may be applied to the above-mentioned electronic device. For example, the storage medium 1000 may include a memory in the electronic device. For the description of the storage medium 1000, reference may be made to the description of the memory in the embodiment of the electronic device, and the repetitive parts will not be repeated. The specific functions and technical effects of the storage medium 1000 may refer to the description of the method for modifying the data of a software object provided in the embodiment of the present application, and will not be repeated here.
[0053] It should be noted that the computer-readable medium described in the embodiments of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a memory card of a smart phone, a storage component of a tablet computer, a portable computer disk, a hard disk of a personal computer, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In an embodiment of the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In an embodiment of the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0054] The computer-readable medium may be included in the electronic device, or may exist independently without being installed in the electronic device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the server, the electronic device implements the method for modifying the data of a software object provided in the embodiment of the present application.
[0055] Computer program code for performing the operations of the disclosed embodiments may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0056] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, which contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they may sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions. The units involved in the embodiments described in the present disclosure can be implemented by software or by hardware. Among them, the name of the unit does not constitute a limitation on the unit itself under certain circumstances. The functions described above in this article can be performed at least in part by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0057] Each embodiment in this specification is described in a progressive 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 storage medium and computing device 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.
[0058] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solution formed by the specific combination of the above-mentioned technical features, but should also cover other technical solutions formed by any combination of the above-mentioned technical features or their equivalent features without departing from the above-mentioned public concept. For example, the above-mentioned features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) to form a technical solution. In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Certain features described in the context of a single embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination.
[0059] The specific implementation methods described above further describe in detail the purpose, technical solutions and beneficial effects of the embodiments of the present invention. Although the subject matter has been described in a language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. It should be understood that the above is only a specific implementation method of the embodiments of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solution of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for modifying data of a software object, comprising: Receiving a target instruction for modifying a target object, parsing the target instruction, and determining at least an operation type of the target instruction and an access path from the target object to target data contained in the target object; The target data is searched from the target object according to the access path, and if the search is successful, the target data is modified at least according to the operation type.
2. The method according to claim 1, wherein: The access path includes a plurality of fields in sequence, the first field of the plurality of fields corresponds to the target object, the last field of the plurality of fields corresponds to the target data, and the other fields of the plurality of fields correspond to intermediate objects between the target object and the target data, and the intermediate objects include single objects or array objects, wherein the post-fields of the corresponding fields of any array object correspond to the array members of the array object.
3. The method according to claim 2, wherein: Searching for the target data from the target object according to the access path includes: The multiple fields are parsed out in sequence from the access path, wherein for each field before the last field, if the field corresponds to a single object, the single object corresponding to the field is obtained by reflection, and the attribute corresponding to the post-field of the field is searched from the attributes included in the single object corresponding to the field; if the field corresponds to an array object, the array member corresponding to the post-field of the field is obtained by reflection according to the subscript of the field and the array member corresponding to the post-field of the field, and the attribute corresponding to the post-field of the field is searched from the attributes included in the array member.
4. The method according to claim 1, wherein: The operation type includes a replacement operation; Parsing the target instruction to at least determine therefrom an operation type of the target instruction and an access path from a target object to target data contained in the target object, comprising: parsing the target instruction to determine therefrom an operation type of the target instruction, an access path from the target object to the target data of the target object, and a target value; Modifying the target data at least according to the operation type includes: if the operation type is a replacement operation, changing the value of the target data according to the target value.
5. The method according to claim 4, wherein: According to the target value, changing the value of the target data includes: If the data type of the target data is a basic type, converting the data type of the target value to the basic type, and changing the value of the target data according to the converted target value; If the data type of the target data is an object type, deserialization is performed according to the target value to obtain an instance of the object type, and the instance is assigned to the target data.
6. The method according to claim 1, wherein: The operation type includes an add operation; Parsing the target instruction to at least determine therefrom an operation type of the target instruction and an access path from a target object to target data contained in the target object, comprising: parsing the target instruction to determine therefrom an operation type of the target instruction, an access path from the target object to the target data of the target object, and a target value; Modifying the data of the target data at least according to the operation type includes: if the operation type is an addition operation, adding array members or attributes included in the target data according to the target value.
7. The method according to claim 1, wherein: The operation type includes a delete operation; Modifying the data of the target data at least according to the operation type includes: if the operation type is a delete operation, setting the value of the target data to a default value.
8. The method according to claim 1, wherein: The operation type includes reordering data; Parsing the target instruction to at least determine therefrom an operation type of the target instruction and an access path from a target object to target data contained in the target object, comprising: parsing the target instruction to determine therefrom an operation type of the target instruction, an access path from the target object to the target data of the target object, and a target value; Modifying the target data at least according to the operation type includes: if the operation type is to reorder the data, reordering the array members included in the target data according to the target value.
9. The method according to claim 1, wherein: The operation type includes a nested operation; Parsing the target instruction to at least determine therefrom an operation type of the target instruction and an access path from a target object to target data contained in the target object, comprising: parsing the target instruction to determine therefrom an operation type of the target instruction, an access path from the target object to the target data of the target object, and a target value; The method further includes: if the operation type is a nested operation, the target value includes one to multiple sub-instructions, and the operation type of each sub-instruction includes one of an addition operation, a deletion operation, a replacement operation, a reordering operation and a nested operation.
10. The method according to claim 1, further comprising: If the search is unsuccessful, the modification of the target data is abandoned.
11. The method according to claim 1, further comprising: If the search is successful, the access path and the modified target data are associated and saved in a predetermined cache, wherein: If the data type of the target data is an object, the access path is associated with the parent object of the target data and the modified target data and saved in the cache; If the data type of the target data is a basic type, the access path, the modified target data, and the class name to which the target data is attributed are associated and saved in the cache.
12. The method according to claim 1, wherein: The target object is a pre-built global singleton object.
13. A device for modifying data of a software object, comprising: a parsing unit configured to receive a target instruction for modifying a target object, parse the target instruction, and determine at least an operation type of the target instruction and an access path from the target object to target data contained in the target object; The modification unit is configured to search for the target data from the target object according to the access path, and if the search is successful, modify the target data at least according to the operation type.
14. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 12.
15. An electronic device comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method according to any one of claims 1 to 12 is implemented.