A cross-platform logical operation expression method and system
By analyzing the custom JSON array format of the original logical expression layer by layer, the problem of lack of simple and easy cross-platform operation analysis logic in the existing technology is solved, and cross-platform logical operation information transmission and simple and easy parsing process are realized.
Patent Information
- Application Number
- CN202111144220.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-28
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2041-09-28
AI Technical Summary
The existing technology lacks simple and easy-to-use cross-platform operational analysis logic.
The parsing of the JSON array format of the original logical expression is performed layer by calling the custom JSON array format, until the parsing of the logical operation result is obtained in advance or the last minimum logical expression parsing is completed to complete the parsing of the JSON array.
The cross-platform logical operation information transmission is realized. The clear-level analysis process is conducive to simple implementation, achieving the simple and easy-to-perform cross-platform logical operation storage analysis effect.
Smart Images

Figure CN113918134B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field related to data transmission, and in particular to a cross-platform logical operation expression method and system. Background Art
[0002] In actual production, we may encounter such a business scenario: a non-computer software developer describes a logical operation formula, which can be visually edited through the web page provided by the developer, and then the developer defines an expression format and stores it through the program. Our system service needs to read this expression, and then parse it through the programming language to obtain the logical operation code of the corresponding programming language.
[0003] Logical operations are also called Boolean operations. Boole used mathematical methods to study logical problems and successfully established logical calculus. He used equations to represent judgments and regarded reasoning as the transformation of equations. The effectiveness of this transformation does not depend on people's interpretation of symbols, but only on the combination rules of symbols. Based on Boolean operations, the existing technology usually uses regular expressions to split strings according to the operation priority, and then performs single logical judgment operations. However, this splitting process is very complicated. It is difficult to split correctly without a deep understanding of regular expressions, and the performance is not optimistic.
[0004] However, the inventors of this application found that the above technology has at least the following technical problems in the process of implementing the technical solution of the invention in the embodiment of this application:
[0005] There is a technical problem in the prior art that there is no simple and easy to use cross-platform computing and parsing logic with good performance. Summary of the invention
[0006] The embodiment of the present application solves the technical problem that there is no simple and high-performance cross-platform operation parsing logic in the prior art by providing a cross-platform logical operation expression method and system. By calling the custom JSON array format of the original logical expression and performing layer-by-layer parsing, the parsing is stopped until the logical operation result is obtained in advance or the last minimum logical expression parsing is completed to obtain the logical operation result, and the parsing of the JSON array is completed to realize cross-platform logical operation information transmission. The clear hierarchical parsing process is conducive to simple implementation, and the technical effect of realizing cross-platform logical operation storage parsing is achieved in a simple and high-performance manner.
[0007] In view of the above problems, an embodiment of the present application provides a cross-platform logical operation expression method and system.
[0008] In a first aspect, an embodiment of the present application provides a cross-platform logical operation expression method, wherein the method includes: obtaining a first original logical expression, the first original logical expression having a first JSON array format; based on the element subscript, performing a positive order loop analysis on a single array element of the first original logical expression to obtain a single array element sequence list; based on the single array element sequence list, determining whether the first array element subscript is less than the first JSON array length; if the first array element subscript is less than the first JSON array length, determining whether the first array element is a minimum logical expression; if the first array element is the minimum logical expression, determining whether a logical operation result of the first array element is true; if the logical operation result of the first array element is true, generating a first loop instruction; and continuing to parse the first original logical expression according to the first loop instruction and the single array element sequence list.
[0009] On the other hand, an embodiment of the present application provides a cross-platform logical operation expression system, wherein the system includes: a first obtaining unit, the first obtaining unit is used to obtain a first original logical expression, and the first original logical expression has a first JSON array format; a second obtaining unit, the second obtaining unit is used to perform a positive order loop analysis on a single array element of the first original logical expression based on the element subscript to obtain a single array element sequence list; a first judgment unit, the first judgment unit is used to judge whether the first array element subscript is less than the first JSON array length based on the single array element sequence list; a second judgment unit, the second judgment unit is used to judge whether the first array element is a minimum logical expression if the first array element subscript is less than the first JSON array length; a third judgment unit, the third judgment unit is used to judge whether the first array element logical operation result is true if the first array element is the minimum logical expression; a first generation unit, the first generation unit is used to generate a first loop instruction if the first array element logical operation result is true; a first parsing unit, the first parsing unit is used to continue parsing the first original logical expression according to the first loop instruction and the single array element sequence list.
[0010] In a third aspect, an embodiment of the present application provides a cross-platform logical operation expression system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the methods described in the first aspect when executing the program.
[0011] One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:
[0012] The invention adopts the following technical scheme: obtaining a first original logical expression, the first original logical expression has a first JSON array format; based on the element subscript, a single array element of the first original logical expression is cyclically parsed in positive order to obtain a single array element sequence list; based on the single array element sequence list, judging whether the first array element subscript is less than the first JSON array length; if the first array element subscript is less than the first JSON array length, judging whether the first array element is the minimum logical expression; if the first array element is the minimum logical expression, judging whether the first array element logical operation result is true; if the first array element logical operation result is true, generating a first loop instruction; according to the first loop instruction and the single array element sequence list, continuing to parse the first original logical expression, the technical scheme is used to call the custom JSON array format of the original logical expression and parse it layer by layer until the parsing obtains the logical operation result in advance or the last minimum logical expression is parsed to obtain the logical operation result, thereby completing the parsing of the JSON array and realizing cross-platform logical operation information transmission. The clearly layered parsing process is conducive to simple implementation, and achieves the technical effect of realizing cross-platform logical operation storage and parsing in a simple and easy manner with excellent performance.
[0013] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 A schematic diagram of a cross-platform logic operation expression method flow in an embodiment of the present application;
[0015] Figure 2 A schematic diagram of a method flow of a cross-platform logical operation multi-layer parsing according to an embodiment of the present application;
[0016] Figure 3 A schematic diagram of the structure of a cross-platform logical operation expression system according to an embodiment of the present application;
[0017] Figure 4 It is a schematic diagram of the structure of an exemplary electronic device according to an embodiment of the present application.
[0018] Explanation of the accompanying drawings: first obtaining unit 11, second obtaining unit 12, first judging unit 13, second judging unit 14, third judging unit 15, first generating unit 16, first parsing unit 17, electronic device 300, memory 301, processor 302, communication interface 303, bus architecture 304. DETAILED DESCRIPTION
[0019] The embodiment of the present application solves the technical problem that there is no simple and high-performance cross-platform operation parsing logic in the prior art by providing a cross-platform logical operation expression method and system. By calling the custom JSON array format of the original logical expression and performing layer-by-layer parsing, the parsing is stopped until the logical operation result is obtained in advance or the last minimum logical expression parsing is completed to obtain the logical operation result, and the parsing of the JSON array is completed to realize cross-platform logical operation information transmission. The clear hierarchical parsing process is conducive to simple implementation, and the technical effect of realizing cross-platform logical operation storage parsing is achieved in a simple and high-performance manner.
[0020] Application Overview
[0021] In actual production, we may encounter such a business scenario: a non-computer software developer describes a logical operation formula, which can be visually edited through the web page provided by the developer, and then the developer defines an expression format and stores it through the program. Our system service needs to read this expression, and then parse it through the programming language to obtain the logical operation code of the corresponding programming language.
[0022] Logical operations are also called Boolean operations. Boole used mathematical methods to study logical problems and successfully established logical calculus. He used equations to represent judgments and regarded reasoning as the transformation of equations. The effectiveness of this transformation does not depend on people's interpretation of symbols, but only on the combination rules of symbols. Based on Boolean operations, the prior art usually uses regular expressions to split strings according to the operation priority, and then performs a single logical judgment operation. However, this splitting process is very complicated. It is difficult to split correctly without a deep understanding of regular expressions, and the performance is not optimistic. However, there is a technical problem in the prior art that there is no simple and easy to use cross-platform operation parsing logic with good performance.
[0023] In response to the above technical problems, the overall idea of the technical solution provided by this application is as follows:
[0024] An embodiment of the present application provides a cross-platform logical operation expression method, wherein the method includes: obtaining a first original logical expression, the first original logical expression having a first JSON array format; based on the element subscript, performing a positive order loop analysis on a single array element of the first original logical expression to obtain a single array element sequence list; based on the single array element sequence list, determining whether the first array element subscript is less than the first JSON array length; if the first array element subscript is less than the first JSON array length, determining whether the first array element is a minimum logical expression; if the first array element is the minimum logical expression, determining whether a result of a logical operation of the first array element is true; if the result of a logical operation of the first array element is true, generating a first loop instruction; and continuing to parse the first original logical expression according to the first loop instruction and the single array element sequence list.
[0025] After introducing the basic principles of the present application, various non-limiting implementation methods of the present application will be specifically described below in conjunction with the drawings in the specification.
[0026] Embodiment 1
[0027] like Figure 1 As shown, an embodiment of the present application provides a cross-platform logical operation expression method, wherein the method includes:
[0028] S100: Obtain a first original logical expression, where the first original logical expression has a first JSON array format;
[0029] Specifically, the first JSON array format refers to a data storage format customized according to the JSON data storage rules; wherein JSON is a lightweight data exchange format. Using a text format that is completely independent of the programming language to store and represent data, the concise and clear hierarchical structure makes JSON an ideal data exchange language, which is easy for people to read and write, and easy for machines to parse and generate, and effectively improves network transmission efficiency. The first original logical expression refers to the expression obtained by characterizing the logical operation that needs to be transmitted across platforms according to the customized first JSON array format. Take an example without limitation: if the first original logic a>2, then the first JSON array format can be customized as: [{"target":"a","operator":">","value":"2"}]: wherein target represents the object to be compared, operator represents the comparison operator, and value represents the comparison object. The first original logic such as a>2, which is a logical operation form consisting of the object to be compared (usually a variable) a, the comparison operator ">", and the comparison object 2, is defined as the minimum original logical operation, and the corresponding object in the first JSON array format such as {"target":"a","operator":">","value":"2"} is the minimum logical expression. In the JSON array, the content in {} is called an object, and [{},{}…{}] is called an array. There can be multiple objects in an array, and there is no "", after the last object. Each basic unit in the array is an element, where the element can preferably be an object, and the object can be in three forms: the first object itself is the minimum logical expression; the second object value is the minimum logical expression; the third object value is an array composed of the minimum logical expressions of multiple logical AND relationships. When the original logic to be stored is a more complex expression that does not conform to the first customized JSON array format, it needs to be converted into a form that conforms to the first customized JSON array format.
[0030] Further, according to the above-mentioned customized first JSON array format minimum logical expression, the first JSON array format of customized complex logical operation symbols or||, and&&, and not! is given as an example without limitation:
[0031] Preferably, the first JSON array format of a>2||b<6 is preferably customized as follows:
[0032] {"condition1":{"target":"a","operator":">","value":"2"},"condition2":{"target":"b","operator":"<","value":"6"}} Such objects represent or|| operations, and when the first JSON array is parsed into a computer expression, it is preferred to use (a>2||b<6) to identify it as a group;
[0033] During the parsing process, the first JSON array format of a>2||b<6 is preferably represented as:
[0034] [{"condition1":{"target":"a","operator":">","value":"2"},"condition2":{"target":"b","operator":"<","value":"6"}}] means unifying the outermost format;
[0035] Preferably, the first JSON array format of a>2&&b<6 is preferably customized as follows:
[0036] [{"target":"a","operator":">","value":"2"},{"target":"b","operator":"<","value":"6"}] This type of array representation, when the first JSON array is parsed into a computer expression, it is preferably marked as a group using (a>2&&b<6), which is preferably a group or multiple groups of minimum logical expressions or "OR operation" forming "AND operation", or a group or multiple groups of minimum logical expressions and "OR operation" forming "AND operation";
[0037] The preferred non-logical operation converts the original logic into the form of && before storage, and then uses the first custom JSON array format of && to express it. By customizing the first JSON array format to express the original logic, the first original logic expression is obtained for storage, and the original logic operation can be stored in a clear hierarchy, which improves the feasibility of subsequent cross-platform transmission.
[0038] S200: Based on the element subscript, perform a circular analysis on the single array element of the first original logical expression in positive order to obtain a single array element sequence list;
[0039] Specifically, after the first original logical expression is stored, it is transmitted to the demand platform and parsed in the demand platform. The element subscript refers to the subscript data set obtained by starting the sequence number from the first element of the first JSON array in positive order until the last element is stopped; the single array element sequence table refers to the parsing of all elements in the first JSON array in positive order according to the element subscript, obtaining multiple single array element sequences, preferably stored in the form of a list and waiting for call; the parsing method is, for example, not limited to: each single array element in the single array element sequence table is parsed in positive order until the logical operation result is obtained or the last element is parsed, completing the cross-platform logical operation transmission.
[0040] S300: Based on the single array element sequence list, determine whether the first array element subscript is less than the first JSON array length;
[0041] Furthermore, the step S300 of determining whether the first array element subscript is less than the first JSON array length further includes:
[0042] S310: If the first array element subscript is not less than the first JSON array length, obtain a first parsing result, the first parsing result including that the first array element is a minimum logical expression;
[0043] S320: Obtain a first return result according to the first parsing result;
[0044] S330: End the current loop analysis according to the first returned result.
[0045] Specifically, after the construction of the single array element sequence list is completed, the first JSON array is preferably parsed according to the positive order of the single array element sequence list. For example, the parsing method is as follows: the first array element refers to the element in the first JSON array corresponding to the positive order subscript of the single array element sequence list, and the subscript is preferably represented by 0, 1, 2, 3, 4...n in sequence, n represents the last element subscript of the first JSON array, and n+1 represents the length of the first JSON array. According to the first original logic operation conversion to the first JSON array expression process, the first array element is parsed into the first original logic operation computer expression in positive order, and the logic operation result is returned, such as: the first array element of the element with subscript 0 is called at the beginning, and after the parsing of the element with subscript 0 is completed and the preset condition is met, the element with subscript 1 is updated to the first array element, until the preset condition is not met to obtain the entire logic operation result or the subscript of the first array element is incremented to n+1 to obtain the entire logic operation result, then the first JSON array parsing is completed, the first parsing result is obtained, and the final first JSON array logic operation result is used as the first return result, the loop is ended, the first return result is fed back, and the parsing is completed. The preset condition is to determine whether the result of the logic operation of the first array element is true. Optionally, based on this logic basis, multi-level training of the intelligent model can be performed to achieve automatic parsing and achieve the technical effect of efficient cross-platform parsing logic operations.
[0046] S400: If the first array element subscript is less than the first JSON array length, determine whether the first array element is a minimum logical expression;
[0047] S500: If the first array element is the minimum logical expression, determine whether the logical operation result of the first array element is true;
[0048] Specifically, before parsing each of the first array elements, it is necessary to determine whether the first array element is the minimum logical expression: when the first array element is the minimum logical expression, a logical operation is performed on the minimum logical expression. When the result of the logical operation is true, it indicates that the parsing of the first array element is completed, and the subscript of the first array element is incremented by +1. When it is determined that the subscript of the first array element is less than the length of the first JSON array, the next element of the first JSON array is parsed until the subscript of the first array element is equal to the length of the first JSON array. When the result of the logical operation is false, because the first array elements are logically ANDed, one group is false, and the result is false, then the result of returning the first JSON array is false. When the first array element is the minimum logical expression, a logical operation is performed on the first array element, and the loop parsing can only be continued when the result of the logical operation is true; when the result of the logical operation is false, the loop ends directly, and the result is returned as false, thereby reducing unnecessary loop processes.
[0049] S600: If the result of the logic operation on the first array element is true, generate a first loop instruction;
[0050] S700: Continue parsing the first original logical expression according to the first loop instruction and the single array element sequence list.
[0051] Specifically, the first loop instruction refers to an instruction generated to continue parsing the first JSON array when the logical operation result of the first array element is true and the first array element subscript is less than the length of the first JSON array; further, when the logical operation result of the first array element is true, the single array element sequence list is continued to be parse in a loop according to the first loop instruction, and if it is encountered that the logical operation result of the array element is false, the logical operation result of the first JSON array is directly returned as false, and if it is always true, the parsing is completed until the first array element subscript is equal to the first JSON array.
[0052] By parsing the first array elements, when parsing, the first array elements are parsed one by one in the positive order of the subscripts of the first array elements. Because the multiple first array elements are in an AND relationship, a logically false result appears, and the result is directly returned as false; if it does not appear, the loop parsing continues until the first JSON array is parsed. If no logically false result appears, the result is returned as true. The parsing results are fed back and called, because the clearly hierarchical parsing process is easy to train and learn, and is conducive to fast parsing, achieving the technical effect of cross-platform, easy and efficient transmission of logical operation data.
[0053] Further, such as Figure 2As shown, the method further includes step S400:
[0054] S410: If the first array element is not the minimum logical expression, perform a deep loop traversal on the first array element to obtain a single element comparison object value set;
[0055] S420: Determine whether the deep loop traversal has ended the loop;
[0056] S430: If the deep loop traversal does not end the loop, determine whether the single element comparison object value set is the minimum logical expression;
[0057] S440: If the single element comparison object value set is not the minimum logical expression, perform deep loop analysis on a single array element of the single element comparison object value set to generate a deep analysis array element sequence list in positive order;
[0058] S450: Based on the deep parsing array element sequence list, determine whether the first deep parsing array element subscript is less than a second JSON array length, wherein the second JSON array length corresponds to the single element comparison object value set;
[0059] S460: If the first deep parsing array element index is not less than the second JSON array length, generate a second loop instruction;
[0060] S470: Continue parsing the first original logical expression according to the second loop instruction and the single array element sequence list.
[0061] Specifically, the single element comparison object value set refers to the result obtained by deeply looping and traversing the first array element when the first array element is not the minimum logical expression; according to the customized first JSON array format, it can be known that the single element comparison object value may be the minimum logical expression or an array composed of multiple minimum logical expressions, and the elements in the single element comparison object value set are all in an or relationship; further, starting from the first element comparison object value of the single element comparison object value set, if the single element comparison object value belongs to the minimum logical expression, a logical operation is performed on the single element comparison object value, and if the result of the logical operation is true, since the elements in the single element comparison object value set are all in an or relationship, the first array element is true, and the loop parsing of the first JSON array continues; if the result of the logical operation is false, it is necessary to loop and traverse and parse the other elements in the single element comparison object value set in turn, and only when the logical operations of the single element comparison object value set are all false, the first array element is false, and the corresponding first JSON array is false, then the loop ends directly, the return result is false, and the parsing is completed.
[0062] If the single element comparison object value belongs to an array composed of multiple minimum logical expressions, it is necessary to perform a loop analysis on the array. Furthermore, the deep analysis array element sequence table refers to the result obtained by deeply traversing and marking the subscripts of the first deep analysis array elements within the single element comparison object value belonging to the array in positive order, and the marking method is the same as the subscript marking method of the array elements in the first JSON array. The second array refers to the single element comparison object value belonging to the array, and is parsed according to the same parsing method as in the first JSON array. The second loop instruction means that when the first deep parsing array element subscript is equal to the second JSON array length, it indicates that the second JSON array parsing is completed, and the logical operation result is true, indicating that the single element comparison object value is true, compared with the logic when it is the minimum logical expression, because the single element comparison object values are in a logical relationship of or, the single element comparison value object set result is true, and the corresponding first array element is also true, then the instruction signal for controlling the continuation of the parsing of the first JSON array is sent; if the logical operation result of any element is false when parsing the second JSON array, the second JSON array is false, and the loop traversal parsing of each element in the single element comparison object value set continues. When the first array element is a complex logical expression, the single element comparison object value set in the first array element is traversed and parsed, and further, when the single element comparison object value is an array, the second JSON array is constructed again and the second JSON array is traversed and parsed using the same method as the first JSON array until the first array element is parsed, and further, the first JSON array is parsed. The recursive parsing method with clear hierarchy combined with similar parsing processes makes the parsing process easy to learn and train.
[0063] Furthermore, the method step S450 further includes:
[0064] S451: If the first deep parsing array element subscript is less than the second JSON array length, and the first deep parsing array element is the minimum logical expression, determine whether the first deep parsing array element logical operation result is true;
[0065] S452: If the result of the first deep analysis array element logic operation is true, recursively and cyclically analyze the array elements of the single element comparison object value set based on the deep analysis array element sequence table.
[0066] Specifically, from the first customized JSON array format, it can be known that the first deep parsing array element must be the minimum logical expression; when parsing the first deep parsing array element, it is only necessary to determine whether the result of the logical operation of the first deep parsing array element is true. When the first deep parsing array element subscript is less than the length of the second JSON array and the result of the logical operation of the first deep parsing array element is true, it indicates that the second JSON array, that is, the array element of the single element comparison object value set, has not been parsed, and the second JSON array continues to be traversed and parsed. The second JSON array is parsed by the same method as the first JSON array parsing method until the result of the logical operation of the second JSON array is obtained. If the result of the logical operation of the second JSON array is true, the loop traversal parsing in the single element comparison object value set is terminated, and the result of the logical operation of the first array element is true, and the traversal parsing of the first JSON array is continued; if the result of the logical operation of the second JSON array is false, it is necessary to continue the traversal parsing in the single element comparison object value set. Based on this, the parsing process of the first customized JSON array format has been clearly explained. Because all more complex logical expressions written by humans can be converted into the first customized JSON array format for storage, the parsing method has a wide range of applicability, and because of the clear hierarchical recursive operations, it is easy to learn and train intelligent parsing models.
[0067] Furthermore, in the step of determining whether the result of the logic operation of the first array element is true, the method step S500 further includes:
[0068] S510: If the result of the logic operation on the first array element is not true, obtain a second return result;
[0069] S520: End the current loop analysis according to the second returned result.
[0070] Specifically, the second returned result refers to when the logical operation result of the first array element is false, because the elements in the first JSON array are in a logical AND relationship, and all logical operation results must be true to be true. Therefore, when the logical operation result of any of the first array elements is false, the logical operation result of the first JSON array is also false, then the logical operation result of the first JSON array is directly returned as the second returned result to complete the parsing. By performing logical operations on the first array elements, a complicated parsing process is avoided, thereby improving the parsing efficiency.
[0071] Furthermore, the method further includes step S800:
[0072] S810: Obtain a first logical operation expression;
[0073] S820: Perform traversal analysis on the first logical operation expression to obtain a minimum logical expression set;
[0074] S830: Obtaining a logical relationship between each minimum logical expression according to the minimum logical expression set;
[0075] S840: Obtaining the objects to be compared, the comparison operators, and the comparison objects of each of the minimum logical expressions;
[0076] S850: Generate the first JSON array format of the first logical operation expression based on the object to be compared, the comparison operator, the comparison object and the logical relationship.
[0077] Specifically, the first logical operation expression refers to the original logical operation formula; before storing the first logical operation expression, that is, in the platform for transmitting data, the first logical operation expression needs to be converted into the first original logical expression having the first JSON array format; the minimum logical expression set refers to traversing the first logical operation expression to extract each individual basic logical operation expression that only includes the object to be compared, the comparison operator and the comparison object; the logical relationship refers to the preferred or, and, not, greater than, less than, equal to and other relationships; the first JSON array format refers to a custom format that can clearly characterize the first logical operation expression and conforms to the format specified by JSON based on the above materials, for example without limitation. : If the first logical operation expression is a>2, the first JSON array format can be customized as: [{"target":"a","operator":">","value":"2"}], where target represents the object to be compared, operator represents the comparison operator, and value represents the comparison object. The first logical operation expression such as a>2, which is composed of the object to be compared (usually a variable) a, the comparison operator">", and the comparison object 2, is defined as the minimum primitive logical operation, and the corresponding object in the first JSON array format such as {"target":"a","operator":">","value":"2"} is the minimum logical expression. In the JSON array, the content in {} is called an object, and [{},{}…{}] is called an array. There can be multiple objects in an array, and there is no "", after the last object. Each basic unit in the array is an element, where the element can preferably be an object, and the object can be in three forms: the first object itself is the minimum logical expression; the second object value is the minimum logical expression; the third object value is an array composed of multiple minimum logical expressions of logical and relationships. When the first logical operation expression to be stored is a more complex expression that does not conform to the first custom JSON array format, it needs to be converted into a form that conforms to the first custom JSON array format for storage, that is, an array format of the form [{},{}…{}].
[0078] Further, according to the above-mentioned customized first JSON array format minimum logical expression, the first JSON array format of customized complex logical operation symbols or||, and&&, and not! is given as an example without limitation:
[0079] Preferably, the first JSON array format of a>2||b<6 is preferably customized as follows:
[0080] {"condition1":{"target":"a","operator":">","value":"2"},"condition2":{"target":"b","operator":"<","value":"6"}} This type of object represents the OR|| operation;
[0081] During the parsing process, the first JSON array format of a>2||b<6 is preferably represented as:
[0082] [{"condition1":{"target":"a","operator":">","value":"2"},"condition2":{"target":"b","operator":"<","value":"6"}}] means unifying the outermost format;
[0083] Preferably, the first JSON array format of a>2&&b<6 is preferably customized as follows:
[0084] It is preferably an "AND operation" composed of one or more groups of minimum logical expressions or / and "OR operation". If the "AND operation" composed of one or more groups of minimum logical expressions is in the form of: [{"target":"a","operator":">","value":"2"},{"target":"b","operator":"<","value":"6"}]; if the first JSON array format of the "AND operation" expression composed of one or more groups of minimum logical expressions and "OR operation" is in the form of:
[0085] [{"target":"c","operator":">","value":"2"},{"condition1":{"target":"a","operator":">","value":"2"}," condition2":[{"target":"b","operator":"<","value":"6"},{"target":"c","operator":"==","value":"3"}]}];
[0086] Preferably, the non-logical operation converts the first logical operation expression into the form of && before storage, and then expresses it using the customized first JSON array format of &&. When the first logical operation expression to be stored is a more complex expression that does not conform to the custom first JSON array format, it needs to be converted into a form that conforms to the custom first JSON array format for storage. For example, the expression [{"target":"a","operator":">","value":"2"},{"target":"b","operator":"<","value":"6"},[{"condition1":{"target":"c","operator":">","value":"2"},"condition2":{"target":"d","operator":"<","value":"6"}}]] can be converted into the custom first JSON array format representation of [{"target":"a","operator":">","value":"2"},{"target":"b","operator":"<","value":"6"},{"condition1":{"target":"c","operator":">","value":"2"},"condition2":{"target":"d","operator":"<","value":"6"}}].
[0087] By customizing the expression of the first JSON array format to obtain the first original logical expression, the first original logical operation can be stored in a more clear hierarchy, thereby improving the feasibility of subsequent cross-platform transmission.
[0088] In summary, the cross-platform logical operation expression method and system provided by the embodiments of the present application have the following technical effects:
[0089] 1. Due to the adoption of obtaining a first original logical expression, the first original logical expression has a first JSON array format; based on the element subscript, a single array element of the first original logical expression is cyclically parsed in positive order to obtain a single array element sequence list; based on the single array element sequence list, whether the first array element subscript is less than the first JSON array length is determined; if the first array element subscript is less than the first JSON array length, whether the first array element is a minimum logical expression is determined; if the first array element is the minimum logical expression, whether the first array element logic operation result is true is determined; if the first array element logic operation result is true, a first loop instruction is generated; according to the first loop instruction and the single array element sequence list, the technical solution of continuing to parse the first original logical expression is achieved, by calling the custom JSON array format of the original logical expression and parsing it layer by layer until the parsing obtains the logic operation result in advance or the last minimum logical expression is parsed to obtain the logic operation result, the parsing of the JSON array is completed, and cross-platform logic operation information transmission is realized. The clear hierarchical parsing process is conducive to simple implementation, and the technical effect of realizing cross-platform operation parsing logic in a simple and easy manner with excellent performance is achieved.
[0090] Embodiment 2
[0091] Based on the same inventive concept as the cross-platform logical operation expression method in the aforementioned embodiment, Figure 3 As shown, the embodiment of the present application provides a cross-platform logical operation expression system, wherein the system includes:
[0092] A first obtaining unit 11, wherein the first obtaining unit 11 is used to obtain a first original logical expression, wherein the first original logical expression has a first JSON array format;
[0093] A second obtaining unit 12, the second obtaining unit 12 is used to perform a circular analysis on a single array element of the first original logical expression in a positive order based on an element subscript to obtain a single array element sequence list;
[0094] A first judging unit 13, the first judging unit 13 is used to judge whether the first array element subscript is less than the first JSON array length based on the single array element sequence list;
[0095] A second judgment unit 14, the second judgment unit 14 is used to judge whether the first array element is a minimum logical expression if the first array element subscript is less than the first JSON array length;
[0096] A third judging unit 15, the third judging unit 15 is used to judge whether the logical operation result of the first array element is true if the first array element is the minimum logical expression;
[0097] A first generating unit 16, the first generating unit 16 is used to generate a first loop instruction if the result of the first array element logic operation is true;
[0098] The first parsing unit 17 is used to continue parsing the first original logical expression according to the first loop instruction and the single array element sequence table.
[0099] Furthermore, the system also includes:
[0100] A first traversal unit, the first traversal unit is used to perform a deep loop traversal on the first array element if the first array element is not the minimum logical expression, to obtain a single element comparison object value set;
[0101] A fourth judgment unit, the fourth judgment unit is used to judge whether the deep loop traversal ends the loop;
[0102] A fifth judgment unit, the fifth judgment unit is used to judge whether the single element comparison object value set is the minimum logical expression if the deep loop traversal does not end the loop;
[0103] A second parsing unit, the second parsing unit is used to perform deep loop parsing on a single array element of the single element comparison object value set to generate a deep parsed array element sequence list in positive order if the single element comparison object value set is not the minimum logical expression;
[0104] a sixth judgment unit, the sixth judgment unit being used to judge whether the first deep parsing array element subscript is less than a second JSON array length based on the deep parsing array element sequence list, wherein the second JSON array length corresponds to the single element comparison object value set;
[0105] A second generating unit, the second generating unit is used to generate a second loop instruction if the first deep parsing array element index is not less than the second JSON array length;
[0106] A third parsing unit, wherein the third parsing unit is used to continue parsing the first original logical expression according to the second loop instruction and the single array element sequence table.
[0107] Furthermore, the system also includes:
[0108] a seventh judgment unit, the seventh judgment unit being configured to judge whether a logical operation result of the first deep parsing array element is true if the first deep parsing array element subscript is less than the second JSON array length and the first deep parsing array element is the minimum logical expression;
[0109] A fourth parsing unit, wherein the fourth parsing unit is used to recursively and cyclically parse the array elements of the single element comparison object value set based on the deep parsing array element sequence table if the result of the first deep parsing array element logic operation is true.
[0110] Furthermore, the system also includes:
[0111] A third obtaining unit, the third obtaining unit being used to obtain a first parsing result if the first array element subscript is not less than the first JSON array length, the first parsing result including that the first array element is a minimum logical expression;
[0112] a fourth obtaining unit, configured to obtain a first returned result according to the first parsing result;
[0113] A first execution unit, wherein the first execution unit is used to end the current loop analysis according to the first returned result.
[0114] Furthermore, the system also includes:
[0115] a fifth obtaining unit, the fifth obtaining unit being used to obtain a second return result if the result of the logic operation of the first array element is not true;
[0116] The second execution unit is used to end the current loop parsing according to the second returned result.
[0117] Furthermore, the system also includes:
[0118] a sixth obtaining unit, the sixth obtaining unit being used to obtain a first logical operation expression;
[0119] A seventh obtaining unit, the seventh obtaining unit is used to perform traversal analysis on the first logical operation expression to obtain a minimum logical expression set;
[0120] an eighth obtaining unit, the eighth obtaining unit being configured to obtain a logical relationship between each minimum logical expression according to the minimum logical expression set;
[0121] A ninth obtaining unit, the ninth obtaining unit being used to obtain the object to be compared, the comparison operator and the comparison object of each minimum logical expression;
[0122] A third generating unit, wherein the third generating unit is used to generate the first JSON array format of the first logical operation expression based on the object to be compared, the comparison operator, the comparison object and the logical relationship.
[0123] Exemplary Electronic Devices
[0124] Reference below Figure 4 To describe the electronic device of the embodiment of the present application,
[0125] Based on the same inventive concept as the cross-platform logic operation expression method in the aforementioned embodiment, the embodiment of the present application also provides a cross-platform logic operation expression system, including: a processor, the processor is coupled to a memory, the memory is used to store a program, when the program is executed by the processor, the system executes the method described in any one of the first aspects
[0126] The electronic device 300 includes: a processor 302, a communication interface 303, and a memory 301. Optionally, the electronic device 300 may also include a bus architecture 304. The communication interface 303, the processor 302, and the memory 301 may be interconnected via the bus architecture 304; the bus architecture 304 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus architecture 304 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0127] The processor 302 may be a CPU, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the program of the present application.
[0128] The communication interface 303 uses any transceiver-like system for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), wired access networks, etc.
[0129] The memory 301 may be a ROM or other type of static storage device that can store static information and instructions, a RAM or other type of dynamic storage device that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory may exist independently and be connected to the processor via the bus architecture 304. The memory may also be integrated with the processor.
[0130] The memory 301 is used to store computer-executable instructions for executing the solution of the present application, and the execution is controlled by the processor 302. The processor 302 is used to execute the computer-executable instructions stored in the memory 301, thereby realizing a cross-platform logical operation expression method provided in the above embodiment of the present application.
[0131] Optionally, the computer-executable instructions in the embodiments of the present application may also be referred to as application code, which is not specifically limited in the embodiments of the present application.
[0132] The embodiment of the present application provides a cross-platform logical operation expression method, wherein the method includes: obtaining a first original logical expression, the first original logical expression having a first JSON array format; based on the element subscript, performing a positive order loop analysis on a single array element of the first original logical expression to obtain a single array element sequence list; based on the single array element sequence list, judging whether the first array element subscript is less than the first JSON array length; if the first array element subscript is less than the first JSON array length, judging whether the first array element is the minimum logical expression; if the first array element is the minimum logical expression, judging whether the first array element logical operation result is true; if the first array element logical operation result is true, generating a first loop instruction; according to the first loop instruction and the single array element sequence list, continuing to parse the first original logical expression. By calling the custom JSON array format of the original logical expression and performing layer-by-layer analysis until the analysis obtains the logical operation result in advance or the last minimum logical expression analysis is completed to obtain the logical operation result, the analysis of the JSON array is completed, and the cross-platform logical operation information transmission is realized. The clear hierarchical analysis process is conducive to simple implementation, and the technical effect of realizing cross-platform operation analysis logic is achieved in a simple and easy manner with excellent performance.
[0133] Those of ordinary skill in the art will appreciate that the various digital numbers such as the first and second involved in the present application are only for the convenience of description, and are not used to limit the scope of the embodiments of the present application, nor do they represent the order of precedence. "And / or" describes the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one" refers to one or more. At least two refers to two or more. "At least one", "any one" or similar expressions refer to any combination of these items, including any combination of single items (individuals) or plural items (individuals). For example, at least one item (individual, kind) of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0134] 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 systems. 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 by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server, data center, etc. 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 semiconductor medium (e.g., a solid-state drive (SSD)), etc.
[0135] The various illustrative logic units and circuits described in the embodiments of the present application can be implemented or operated by a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic system, a discrete gate or transistor logic, a discrete hardware component, or the design of any combination of the above functions. The general-purpose processor can be a microprocessor, and optionally, the general-purpose processor can also be any traditional processor, controller, microcontroller or state machine. The processor can also be implemented by a combination of a computing system, such as a digital signal processor and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a digital signal processor core, or any other similar configuration to implement.
[0136] The steps of the method or algorithm described in the embodiments of the present application can be directly embedded in hardware, a software unit executed by a processor, or a combination of the two. The software unit can be stored in a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium in the art. Exemplarily, the storage medium can be connected to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Optionally, the storage medium can also be integrated into the processor. The processor and the storage medium can be arranged in an ASIC, and the ASIC can be arranged in a terminal. Optionally, the processor and the storage medium can also be arranged in different components in the terminal. These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are performed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0137] Although the present application has been described in conjunction with specific features and embodiments thereof, it is obvious that various modifications and combinations may be made thereto without departing from the spirit and scope of the present application. Accordingly, this specification and the drawings are merely exemplary illustrations of the present application as defined by the appended claims, and are deemed to have covered any and all modifications, variations, combinations or equivalents within the scope of the present application. Obviously, a person skilled in the art may make various modifications and variations to the present application without departing from the scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include these modifications and variations.
Claims
1. A cross-platform logical operation expression method, wherein: The method comprises: Obtaining a first original logical expression, wherein the first original logical expression has a first JSON array format, and the first original logical expression refers to an expression obtained by characterizing a logical operation that needs to be transmitted across platforms according to the first custom JSON array format; Based on the element subscript, a single array element of the first original logical expression is cyclically parsed in positive order to obtain a single array element sequence list, wherein the element subscript refers to a subscript data set obtained by starting from the first element of the first JSON array in positive order and stopping at the last element; Based on the single array element sequence list, determine whether the first array element subscript is less than the first JSON array length; If the first array element subscript is less than the first JSON array length, determine whether the first array element is a minimum logical expression, where the minimum logical expression is determined based on the content of the element in the array in the first custom JSON array format; If the first array element is the minimum logical expression, determining whether the result of the logical operation of the first array element is true; If the result of the logic operation on the first array element is true, generating a first loop instruction; According to the first loop instruction and the single array element sequence table, the first original logic expression continues to be parsed until the last element is parsed, thereby completing the cross-platform logic operation transmission.
2. The method of claim 1, wherein: The method further comprises: If the first array element is not the minimum logical expression, performing a deep loop traversal on the first array element to obtain a single element comparison object value set; Determine whether the deep loop traversal ends the loop; If the deep loop traversal does not end the loop, determining whether the single element comparison object value set is the minimum logical expression; If the single element comparison object value set is not the minimum logical expression, performing deep loop analysis on a single array element of the single element comparison object value set to generate a deep analysis array element sequence list in positive order; Based on the deep parsing array element sequence list, determining whether the first deep parsing array element subscript is less than a second JSON array length, wherein the second JSON array length corresponds to the single element comparison object value set; If the first deep parsing array element index is not less than the second JSON array length, generate a second loop instruction; The first original logical expression continues to be parsed according to the second loop instruction and the single array element sequence list.
3. The method of claim 2, wherein: The method further comprises: If the first deep parsing array element subscript is less than the second JSON array length, and the first deep parsing array element is the minimum logical expression, determine whether the first deep parsing array element logical operation result is true; If the result of the first deep analysis array element logic operation is true, a recursive loop analysis is performed on the array elements of the single element comparison object value set based on the deep analysis array element sequence table.
4. The method of claim 1, wherein: The step of determining whether the first array element subscript is less than the first JSON array length further includes: If the first array element subscript is not less than the first JSON array length, a first parsing result is obtained, wherein the first parsing result includes that the first array element is a minimum logical expression; Obtaining a first return result according to the first parsing result; According to the first returned result, the current loop parsing ends.
5. The method of claim 1, wherein: The step of determining whether the result of the logic operation of the first array element is true further includes: If the result of the logical operation of the first array element is not true, obtaining a second return result; According to the second returned result, the current loop parsing ends.
6. The method of claim 1, wherein: The method further comprises: Obtaining a first logical operation expression; Performing traversal analysis on the first logical operation expression to obtain a minimum logical expression set; According to the minimum logical expression set, obtaining the logical relationship between the minimum logical expressions; Obtaining the objects to be compared, the comparison operators and the comparison objects of each of the minimum logical expressions; Based on the objects to be compared, the comparison operator, the comparison objects, and the logical relationship, the first JSON array format of the first logical operation expression is generated.
7. A cross-platform logical operation expression system, wherein: The system comprises: A first obtaining unit, the first obtaining unit is used to obtain a first original logical expression, the first original logical expression has a first JSON array format, and the first original logical expression refers to an expression obtained by characterizing a logical operation that needs to be transmitted across platforms according to the first custom JSON array format; A second obtaining unit, the second obtaining unit is used to perform a positive order loop analysis on a single array element of the first original logical expression based on an element subscript, to obtain a single array element sequence list, wherein the element subscript refers to a subscript data set obtained by starting from the first element of the first JSON array in positive order and stopping at the last element; A first judgment unit, the first judgment unit is used to judge whether the first array element subscript is less than the first JSON array length based on the single array element sequence list; A second judgment unit, the second judgment unit is used to judge whether the first array element is a minimum logical expression if the first array element subscript is less than the first JSON array length, and the minimum logical expression is determined according to the content of the element in the array in the first custom JSON array format; a third judgment unit, the third judgment unit being used to judge whether a logical operation result of the first array element is true if the first array element is the minimum logical expression; A first generating unit, the first generating unit being configured to generate a first loop instruction if a result of a logic operation on the first array element is true; The first parsing unit is used to continue parsing the first original logical expression according to the first loop instruction and the single array element sequence table until the last element is parsed, thereby completing the cross-platform logical operation transmission.
8. A cross-platform logical operation expression system, comprising: A processor, the processor is coupled to a memory, the memory is used to store a program, when the program is executed by the processor, the system executes the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Data processing method and device
CN109766100A
Data display method and system, data editing method and system, equipment and medium
CN111435372A