CN110162307A - A kind of method and device that JSON file is converted to dll file - Google Patents

A kind of method and device that JSON file is converted to dll file Download PDF

Info

Publication number
CN110162307A
CN110162307A CN201910314155.5A CN201910314155A CN110162307A CN 110162307 A CN110162307 A CN 110162307A CN 201910314155 A CN201910314155 A CN 201910314155A CN 110162307 A CN110162307 A CN 110162307A
Authority
CN
China
Prior art keywords
class
information
data format
typesetting
json
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910314155.5A
Other languages
Chinese (zh)
Other versions
CN110162307B (en
Inventor
汤平
刘作斌
林松青
陈禹
鲍美芳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujian Nebula Electronics Co Ltd
Original Assignee
Fujian Nebula Electronics Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Fujian Nebula Electronics Co Ltd filed Critical Fujian Nebula Electronics Co Ltd
Priority to CN201910314155.5A priority Critical patent/CN110162307B/en
Publication of CN110162307A publication Critical patent/CN110162307A/en
Application granted granted Critical
Publication of CN110162307B publication Critical patent/CN110162307B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/51Source to source
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Abstract

The present invention provides a kind of method that JSON file is converted to dll file, the JSON data format text that the manufacturing execution system including receiving input provides;The XML data format text that JSON data format text conversion is used at C# programming language;The basic element information in XML data format text is read, the basic element information includes the data information for generating class;Data information is subjected to typesetting according to the typesetting format of class, and obtains typesetting result;It calls the function library in C# programming language that typesetting result is generated dll file, and is saved in specified path.The present invention also provides devices corresponding to a kind of method.The invention has the advantages that have the smallest system dependence, be easy deployment, it is simple small and exquisite convenient the advantages that;Simultaneously as sequencing operation, so that the typesetting that the data information of JSON data format carries out class (Class) is easy to operate;Also the dll file result ultimately generated is made to be applicable to the calling of other programs.

Description

A kind of method and device that JSON file is converted to dll file
Technical field
The present invention relates to document data process field more particularly to a kind of methods that JSON file is converted to dll file And device.
Background technique
Data interchange format of the JSON (JavaScriptObjectNotation) as a kind of lightweight, in program development It is often used in the process.JSON is a subset based on ECMAScript, and JSON is using the text for being totally independent of language This format, but also use similar to C language family habit (including C, C++, C#, Java, JavaScript, Perl, Python etc.), these characteristics make JSON become ideal data interchange language, are easy to people and read and write, while being also easy to machine Device parsing and generation.
Currently, the data format that manufacturing execution system (MES) needs to upload all is much JSON format, and programmed using C# During language development, the operation of JSON data format is needed to carry out data conversion, it is more convenient for being converted to class (Class) A kind of mode of operation.Class (Class) is actually to certain type of object definition variable and method in C# programming language Prototype, it is indicated to the abstract of the things with common trait a kind of in actual life, is the basis of Object-Oriented Programming.But class (Class) text is can not to be used by program, it could be by program after needing the file by being compiled into the formats such as DLL/EXE It is used.
For application developer, by JSON Data Format Transform at DLL formatted file, present industry compares stream Capable several schemes for being converted to DLL formatted file include:
Scheme one, manual type first analyze JSON formatted data, write class (Class) text further according to the result of analysis, Class (Class) text is finally compiled by dll file by compiler again;
Scheme two uses third party's tool mode, duplication JSON formatted data, using selective in VisualStudio It pastes, JSON is pasted for class (Class) text, class (Class) text is finally compiled into dll file again.
Although the methods of above 2 kinds of generations dll file are more popular, specific occasion still can embody it is some not Foot, is set forth below:
The shortcomings that scheme one: manual analysis JSON needs take a certain time and energy, then write out class (Class) text manually This, the mistakes such as name is lack of standardization are easy to produce during this, when encounter JSON data format it is more complicated when, when just spending more Between, and error rate can increase.
The shortcomings that scheme two: in the program for having used dynamic compilation techniques, needing authorization business using third party's tool, This just will increase expense cost, and different software switching can be to user with bringing hostile user to experience.
Summary of the invention
The technical problem to be solved in the present invention is to provide a kind of method and dress that JSON file is converted to dll file It sets, the software operation that software developer can be facilitated to interact in exploitation with manufacturing execution system (MES) in the past will to solve It needs professional come the problem of operation when JSON Data Format Transform is at dll file, and needs by means of third party's tool The problem of.
The present invention is implemented as follows: a kind of method that JSON file is converted to dll file, the method includes as follows Step:
Step S1, the JSON data format text that the manufacturing execution system of input provides is received;
Step S2, the XML data format text for using JSON data format text conversion at C# programming language;
Step S3, the basic element information in XML data format text is read, the basic element information includes for giving birth to At the data information of class;
Step S4, data information is subjected to typesetting according to the typesetting format of class, and obtains typesetting result;
Step S5, it calls the function library in C# programming language that typesetting result is generated dll file, and is saved in specified circuit Diameter.
Further, the step S2 specifically:
The XML for being used JSON data format text conversion at C# programming language using Newtonsoft.Json function library Data format text, and obtain XML data format text results.
Further, the step S3 specifically:
The basic element information in XML data format text is read using the function library traversal in C# programming language, it is described Basic element information includes the data information for generating class;
Wherein, the basic element information read in XML data format text specifically includes:
The Property Name information for generating class is read, the Property Name information is located at the XML data format text Nodal information in;
The attribute type information for generating class is read, the attribute type information is located at the section of the XML data format In point value;
The composed structure information for generating class is read, the composed structure information is located at the father of the XML data format In nodal information, and the data information in a father node is for generating a class text.
Further, the step S4 specifically:
All data informations that traversal is read out carry out typesetting according to the typesetting format of class, and specific typesetting operation includes: By the title after the initial caps of the nodename of father node as class, by the head of the nodename of the child node of the father node As the attribute of class after letter capitalization, and judge according to the nodal value of the child node of the father node Attribute class of the attribute of class Type;
Meanwhile if there are also junior's child node below the child node of the father node, using the child node of the father node as Father node, and repeat above-mentioned typesetting operation;
After completing typesetting operation, typesetting result is obtained.
Further, the step S5 is specifically included:
Step S51, according to the type information of class, compiler object is created;
Step S52, it according to the reference information of class, creates and compiling parameter object is set;
Step S53, according to specified storing path, DLL object is created, typesetting result is generated into dll file to realize And it is saved in specified path.
The present invention is implemented as follows: a kind of device that JSON file is converted to dll file, described device include JSON Read module, format converting module, XML read module, type-setting module and generation module;
The JSON read module, the JSON data format text that manufacturing execution system for receiving input provides;
The format converting module, the XML data for using JSON data format text conversion at C# programming language Format text;
The XML read module, for reading the basic element information in XML data format text, the basic element Information includes the data information for generating class;
The type-setting module for data information to be carried out typesetting according to the typesetting format of class, and obtains typesetting result;
The generation module for calling the function library in C# programming language that typesetting result is generated dll file, and is protected It is stored to specified path.
Further, the format converting module specifically:
The XML for being used JSON data format text conversion at C# programming language using Newtonsoft.Json function library Data format text, and obtain XML data format text results.
Further, the XML read module specifically:
The basic element information in XML data format text is read using the function library traversal in C# programming language, it is described Basic element information includes the data information for generating class;
Wherein, the basic element information read in XML data format text specifically includes:
The Property Name information for generating class is read, the Property Name information is located at the XML data format text Nodal information in;
The attribute type information for generating class is read, the attribute type information is located at the section of the XML data format In point value;
The composed structure information for generating class is read, the composed structure information is located at the father of the XML data format In nodal information, and the data information in a father node is for generating a class text.
Further, the type-setting module specifically:
All data informations that traversal is read out carry out typesetting according to the typesetting format of class, and specific typesetting operation includes: By the title after the initial caps of the nodename of father node as class, by the head of the nodename of the child node of the father node As the attribute of class after letter capitalization, and judge according to the nodal value of the child node of the father node Attribute class of the attribute of class Type;
Meanwhile if there are also junior's child node below the child node of the father node, using the child node of the father node as Father node, and repeat above-mentioned typesetting operation;
After completing typesetting operation, typesetting result is obtained.
Further, the generation module specifically includes compiler-creating unit, parameter set unit and result and generates Unit;
The compiler-creating unit creates compiler object for the type information according to class;
The parameter set unit creates for the reference information according to class and compiling parameter object is arranged;
The result generation unit, for creating DLL object according to specified storing path, to realize typesetting knot Fruit generates dll file and is saved in specified path.
The present invention has the advantage that the present invention passes through in interface input box input manufacturing execution system (MES) offer JSON data format text automatically generates the corresponding dll file used for developer, and there is the smallest system to rely on Property, be easy deployment, it is simple small and exquisite convenient the advantages that;Simultaneously as sequencing operation, so that the data of JSON data format are believed The typesetting that breath carries out class (Class) is easy to operate;Also the dll file result ultimately generated is made to be applicable to the tune of other programs With.
Detailed description of the invention
The present invention is further illustrated in conjunction with the embodiments with reference to the accompanying drawings.
Fig. 1 is a kind of execution flow chart for the method that JSON file is converted to dll file of the present invention.
Specific embodiment
Refering to Figure 1, a kind of method that JSON file is converted to dll file of the present invention, it is characterised in that: described Method includes the following steps:
Step S1, the JSON data format text that the manufacturing execution system (MES) of input provides is received;
Step S2, the XML data format text for using JSON data format text conversion at C# programming language;
Step S3, the basic element information in XML data format text is read, the basic element information includes for giving birth to At the data information of class;
Step S4, data information is subjected to typesetting according to the typesetting format of class, and obtains typesetting result;
Step S5, it calls the function library in C# programming language that typesetting result is generated dll file, and is saved in specified circuit Diameter.
In the step S1, the JSON data format text that manufacturing execution system (MES) provides is a kind of message model essay, Manufacturing execution system could be obtained to manufacturing execution system (MES) by only strictly observing data format transmission JSON data (MES) correct response.For example, the JSON data that manufacturing execution system (MES) provides in the present embodiment can be following format:
Stu:[{ " name ": " Zhang San ", " address ": " city XX Dongcheng District ", " age ": 25, " book ": [" Name ": " Chinese language " }, { " name ": " mathematics " }], " score ": { " English ": " 90 " } },
{ " name ": " Li Si ", " address ": " city xx Xicheng District ", " age ": 22 }] }.
The step S2 specifically: using Newtonsoft.Json function library by JSON data format text conversion at C# The XML data format text that programming language uses, and obtain XML data format text results.For example, being converted into the present embodiment XML data format text can be following format:
Wherein,
XML data format are as follows: XML extensible markup language (EXtensibleMarkupLanguage), standard universal mark The subset for remembering language, is a kind of for marking electronic document to make it have structural markup language;XML and operating system are compiled Cheng Yuyan and development platform are unrelated, it can be achieved that the not data interaction between homologous ray, different language.
Newtonsoft.Json function library are as follows: Newtonsoft.Json, it is the Json sequence increased income in a .NET Change and unserializing class libraries (download address is http://json.codeplex.com/).
The step S3 specifically: read in XML data format text using the function library traversal in C# programming language Basic element information, the basic element information include the data information for generating class (Class);
Wherein, the basic element information read in XML data format text specifically includes:
The Property Name information for generating class (Class) is read, the Property Name information is located at the XML data lattice In the nodal information of formula text;
The attribute type information for generating class (Class) is read, the attribute type information is located at the XML data lattice In the nodal value of formula;
The composed structure information for generating class (Class) is read, the composed structure information is located at the XML data lattice In the parent information of formula, and the data information in a father node is for generating a class text.
In XML data format text, the nodal information that be located at XML data format text can be used for the class of generation (Class) Property Name information, the category for the class (Class) that the nodal value for being located at XML data format text can be used to generate Property type information, the father node title of XML data format text can be used for generate a self defined class (Class), one Data information in father node is for generating the self defined class (Class) and such attribute, if there are also continue if child node Traversal is read, and is completed until all nodes all traverse reading.The present invention takes full advantage of the nodal properties of XML data format: son Node corresponds to the attribute of class, and father node corresponds to class;The implementation method is simple to operation, enormously simplifies and generates class (Class) text This process and the difficulty for reducing generation class (Class) text.
Node in XML data format text are as follows: XML file is made of node, its first node is " root Node ".One XML file must have and can only have a root node, other nodes all must be its child node;Every height section Point can have the child node of oneself again, and each node has nodename and nodal value.
It elaborates combined with specific embodiments below to XML data format text, such as XML data format text Particular content are as follows:
Entire XML data format text, is divided into one " root node " and several " child nodes ", wherein each child node is again There can be a child node of oneself, i.e. the child node father node that is known as its child node.Wherein containing in parent information will The information of the class (Class) of generation contains the class that will be generated in the nodename and node value information of each node (Class) attribute information.
The step S4 specifically:
All data informations that traversal is read out carry out typesetting, specific typesetting behaviour according to the typesetting format of class (Class) Work includes: by the title after the initial caps of the nodename of father node as class (Class), by the child node of the father node Nodename initial caps after attribute as class (Class), and sentenced according to the nodal value of the child node of the father node The attribute type of the disconnected attribute of class (Class) out;
Meanwhile if there are also junior's child node below the child node of the father node, using the child node of the father node as Father node, and repeat above-mentioned typesetting operation;
After completing typesetting operation, typesetting result is obtained.
Below using a simple XML data format text as example, to by XML data format text according to class (Class) process that typesetting format carries out typesetting is described in detail:
For example, there is an XML data format text:
Wherein, it is also a father node that ' student ' in XML data format text, which is its root node, represents a class (Class) information, the present invention in, by inside nodal information nodename and nodal value be expressed as the class to be generated (Class) attribute.
In the above example, the initial caps of the entitled father node title of class (Class), it may be assumed that Student, it should Student class has three name, address, age attributes;
Attribute information is respectively:
Property Name: name, attribute type: character type;
Property Name: address, attribute type: character type;
Property Name: age, attribute type: integer;
In above-mentioned XML data format text,<student>...</student>for a father node, nodename is ' student ', nodal value are three child nodes, and three child nodes are respectively<name>...</name>,<address>...</ address>,<age>…</age>.Wherein<name>...</name>the nodename of node is ' name ', and nodal value is ' Zhang San ';<address>...</address>the nodename of node is ' address ', and nodal value is ' city XX Xicheng District '; <age>...</age>the nodename of node is ' age ', nodal value 22.It corresponds to entitled for one in class (Class) The student model class of ' Student ', there are three attribute, respectively name (name), address (address) and age (age), Wherein name (name) and address (address) is character type (String), and age (age) is integer (Int32).It indicates text This is as follows:
Below by step S2 generate XML data format text for, to by XML data format text according to class (Class) process that typesetting format carries out typesetting is described in detail again:
Wherein, it is also a father node that ' Root ' of XML data format text, which is its root node, represents a class (Class) information, the present invention in, by inside nodal information nodename and nodal value be expressed as the class to be generated (Class) attribute.
In this example embodiment, father node is respectively as follows:<root>...</Root>,<stu>...</stu>,<book>...</book >,<score>...</score>, entitled Root, Stu, Book, Score of corresponding class (Class) are saved further according to these fathers The child node information of point, it can be deduced that attribute information;
Wherein, Root generic attribute information is:
Property Name: stu, attribute type: customization type (Stu);
Wherein, Stu generic attribute information is:
Property Name: name, attribute type: character type;
Property Name: address, attribute type: character type;
Property Name: age, attribute type: integer;
Property Name: book, attribute type: customization type (Book);
Property Name: score, attribute type: customization type (Score);
Wherein, Book generic attribute information is:
Property Name: name, attribute type: character type;
Wherein, Score generic attribute information is:
Property Name: English, attribute type: floating type type;
Customization type are as follows: General System data type has integer, character type, floating type etc..In C# programming language for General system array type, user can also define the data type of oneself, and identical data type often has identical Size and coding mode.Array and set are all a kind of more special data types.
Next, will also according to the number occurred in peer with name node to determine whether be array type, or with For above-mentioned file:
<stu>...</stu>, this node exists<root>...</Root>occur under node twice, due to class (Class) It is provided in definition, same type of Property Name is not reproducible, therefore will<stu>...</stu>the corresponding attribute of node is arranged to Array mode indicates.So modification Root generic attribute information are as follows: Property Name: stu, attribute type: customization type set (IList<Stu>);
<book>...</book>, this node exists<stu>...</stu>occur under node twice, due to class (Class) It is provided in definition, same type of Property Name is not reproducible, therefore will<book>...</book>the corresponding attribute setting of node It is indicated at array mode.So modification Stu generic attribute information are as follows: Property Name: book, attribute type: customization type collection It closes (IList<Book>);
Therefore, content is as follows after the attribute type by modifying class:
Wherein, Root generic attribute information is:
Property Name: stu, attribute type: customization type set (IList<Stu>);
Wherein, Stu generic attribute information is:
Property Name: name, attribute type: character type;
Property Name: address, attribute type: character type;
Property Name: age, attribute type: integer;
Property Name: book, attribute type: customization type set (IList<Book>);
Property Name: score, attribute type: customization type (Score);
Wherein, Book generic attribute information is:
Property Name: name, attribute type: character type;
Wherein, Score generic attribute information is:
Property Name: English, attribute type: type double precision.
Due in the grammer of C# programming language, the representation of class (Class) are as follows:
Therefore, by the class name of four classes saved in above-mentioned file and the attribute information of class according to the typesetting of class (Class) It is as follows that format carries out the four class results obtained after typesetting:
The step S5 is specifically included:
Step S51, according to the type information of class, compiler object is created;
Step S52, it according to the reference information of class, creates and compiling parameter object is set;
Step S53, according to specified storing path, DLL object is created, typesetting result is generated into dll file to realize And it is saved in specified path.
Text information due to generating class (Class) in step s 4 can not be used by applications, it needs to pass through Being compiled into after the file of the formats such as DLL/EXE can just be used by applications.By calling the function library of C# compiler language dynamic The file of DLL/EXE format is produced after the text information of state compiling class (Class) and is saved in specified path.
Meanwhile in order to allow the dll file of compiling generation cited in outside, it is also necessary to for the class (Class) generated In addition NameSpace.There is the description to the type of attribute in the class (Class) of generation, but the class (Class) generated does not include class The definition of type, it is desirable to by compiling, then need to add using indicator, quote System NameSpace, contained in the space The definition of system common type.Therefore it needs class (Class) text that step S4 is generated making following modification:
Modifying point is that joined ' usingXXX ' in class (Class) text head position;Using indicator quotes System NameSpace and System.Collections.Generic NameSpace add in the periphery for four classes that step S4 is generated The NameSpace of ' namespaceNebulaNameSpace ' is simultaneously wrapped with braces.
NameSpace are as follows: namespace, i.e. NameSpace refer to the various visible ranges of identifier.In C# programming language Using single global variable NameSpace, in this single space, if there are two the name of variable or function is complete It is exactly the same, it just will appear conflict.
Using indicator are as follows: using indicator makes name space member name as it can be seen that just look like them being in name space It is declared the same except the place being defined;Using indicator is not the name statement part of name space member Alias, but the member of name space is transferred in that domain comprising the namespace definition;Program beginning can be used Using pragma come using the name in NameSpace.System is the most basic name that .NET platform framework provides One of space.
The function library how called in C# programming language is done typesetting result generation dll file specifically below It is bright:
The first step creates compiler object;
Such as: CodeDomProviderprovider=CodeDomProvider.CreateProvider (" cs ");
Compiler object is created according to appointed language;For example, in embodiments of the present invention, the title of the appointed language of generation For " cs ", illustrate that the code to be compiled is C# language format.
Second step creates and compiling parameter object is arranged;Such as:
CompilerParametersp=newCompilerParameters ();
p.ReferencedAssemblies.Add("System.dll");
Parameter value " System.dll " illustrates to add the parameter in parameter, joined in class (Class) text head position ‘usingSystem';System NameSpace is quoted, which is located in ' System.dll ', by file name with parameter The clearly incoming compiler of form.
Third step creates DLL object according to specified storing path.
For example, the output position of setting compiling parameter, then carries out on-the-flier compiler, mode is as follows:
The file of generation is stored in the path " C: MesData.dll " by the output position information of // setting parameter;
P.OutputAssembly=" C: MesData.dll ";
// call compiler ' CompileAssemblyFromSource ' Compilation Method to be compiled
provider.CompileAssemblyFromSource(p,csStr);
Compiler object " provider " is the C# language compiler object of first step creation, and first parameter value " p " is The compiling parameter of second step creation, third parameter " csStr " are class (Class) text finally modified in step S5.Pass through Above step, which realizes, calls C# function that the file of typesetted class (Class) is converted to dll file.
In the above-mentioned methods, if can also reach same effect using the third parties such as VisualStudio tool, but make It in program with dynamic compilation techniques, needs to authorize using third party's tool, is easy to produce the nonstandard mistake of name, and meeting To user with bringing hostile user to experience.
In addition, JSON Data Format Transform at class (Class), is just not necessarily to by application developer after using this method Class (Class) is write after manual analysis JSON format again, reduces development time and energy, reduces probability of making mistakes.It is using In the program of dynamic compilation techniques, after this method, alternative third party's tool reduces purchase authorization cost.It can also be with Control Naming conventions well, use also more convenient.When the JSON file to be converted is more, the method, tool can be used There is better working efficiency.
When specifically used, the method provided by the invention that JSON file is converted to dll file can regard one light as Magnitude compilation tool, operator need to only copy to the model essay of the JSON data format of demand in manufacturing execution system (MES) In the input frame of the compilation tool, then clicks button and execute data conversion, so that it may data be viewed by output window and turned Changing result, (whether operator can meet expection by the result data that output window inspection is converted, if not meeting and being expected Can modify), while the dll file ultimately generated can be saved in specified catalogue.It is inputted in this method by interface Frame inputs the JSON data format text that manufacturing execution system (MES) is provided, and automatically generates corresponding for developer's use Dll file, there is the smallest system dependence, be easy deployment, it is simple small and exquisite convenient the advantages that;Simultaneously as sequencing Operation, so that the typesetting that the data information of JSON data format carries out class (Class) is easy to operate;Also make the DLL ultimately generated Document result is applicable to the calling of other programs.
It is described the present invention also provides a kind of device that JSON file is converted to dll file based on identical inventive concept Device includes JSON read module, format converting module, XML read module, type-setting module and generation module;
The JSON read module, the JSON data format text that manufacturing execution system for receiving input provides;
The format converting module, the XML data for using JSON data format text conversion at C# programming language Format text;
The XML read module, for reading the basic element information in XML data format text, the basic element Information includes the data information for generating class;
The type-setting module for data information to be carried out typesetting according to the typesetting format of class, and obtains typesetting result;
The generation module for calling the function library in C# programming language that typesetting result is generated dll file, and is protected It is stored to specified path.
The format converting module specifically:
The XML for being used JSON data format text conversion at C# programming language using Newtonsoft.Json function library Data format text, and obtain XML data format text results.
The XML read module specifically:
The basic element information in XML data format text is read using the function library traversal in C# programming language, it is described Basic element information includes the data information for generating class;
Wherein, the basic element information read in XML data format text specifically includes:
The Property Name information for generating class is read, the Property Name information is located at the XML data format text Nodal information in;
The attribute type information for generating class is read, the attribute type information is located at the section of the XML data format In point value;
The composed structure information for generating class is read, the composed structure information is located at the father of the XML data format In nodal information, and the data information in a father node is for generating a class text.
The type-setting module specifically:
All data informations that traversal is read out carry out typesetting according to the typesetting format of class, and specific typesetting operation includes: By the title after the initial caps of the nodename of father node as class, by the head of the nodename of the child node of the father node As the attribute of class after letter capitalization, and judge according to the nodal value of the child node of the father node Attribute class of the attribute of class Type;
Meanwhile if there are also junior's child node below the child node of the father node, using the child node of the father node as Father node, and repeat above-mentioned typesetting operation;
After completing typesetting operation, typesetting result is obtained.
The generation module specifically includes compiler-creating unit, parameter set unit and result generation unit;
The compiler-creating unit creates compiler object for the type information according to class;
The parameter set unit creates for the reference information according to class and compiling parameter object is arranged;
The result generation unit, for creating DLL object according to specified storing path, to realize typesetting knot Fruit generates dll file and is saved in specified path.
Apparatus of the present invention are flow chart and/or the side of the method and computer program product referring to the specific embodiment of the invention Block diagram describes.It should be understood that each process and/or the side in flowchart and/or the block diagram can be realized by computer program instructions The combination of process and/or box in frame and flowchart and/or the block diagram.These computer program instructions be can provide to logical With the processor of computer, special purpose computer, Embedded Processor or other programmable data processing devices to generate a machine Device, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for realizing in process The device for the function of being specified in figure one process or multiple processes and/or block diagrams one box or multiple boxes.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates, Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one The step of function of being specified in a box or multiple boxes.
Although specific embodiments of the present invention have been described above, those familiar with the art should be managed Solution, we are merely exemplary described specific embodiment, rather than for the restriction to the scope of the present invention, it is familiar with this The technical staff in field should be covered of the invention according to modification and variation equivalent made by spirit of the invention In scope of the claimed protection.

Claims (10)

1. a kind of method that JSON file is converted to dll file, it is characterised in that: described method includes following steps:
Step S1, the JSON data format text that the manufacturing execution system of input provides is received;
Step S2, the XML data format text for using JSON data format text conversion at C# programming language;
Step S3, the basic element information in XML data format text is read, the basic element information includes for generating class Data information;
Step S4, data information is subjected to typesetting according to the typesetting format of class, and obtains typesetting result;
Step S5, it calls the function library in C# programming language that typesetting result is generated dll file, and is saved in specified path.
2. a kind of method that JSON file is converted to dll file according to claim 1, it is characterised in that: the step Rapid S2 specifically:
The XML data for being used JSON data format text conversion at C# programming language using Newtonsoft.Json function library Format text, and obtain XML data format text results.
3. a kind of method that JSON file is converted to dll file according to claim 1, it is characterised in that: the step Rapid S3 specifically:
The basic element information in XML data format text is read using the function library traversal in C# programming language, it is described basic Element information includes the data information for generating class;
Wherein, the basic element information read in XML data format text specifically includes:
The Property Name information for generating class is read, the Property Name information is located at the section of the XML data format text In point information;
The attribute type information for generating class is read, the attribute type information is located at the nodal value of the XML data format In;
The composed structure information for generating class is read, the composed structure information is located at the father node of the XML data format In information, and the data information in a father node is for generating a class text.
4. a kind of method that JSON file is converted to dll file according to claim 1, it is characterised in that: the step Rapid S4 specifically:
All data informations that traversal is read out carry out typesetting according to the typesetting format of class, and specific typesetting operation includes: by father As the title of class after the initial caps of the nodename of node, by the initial of the nodename of the child node of the father node As the attribute of class after capitalization, and judge according to the nodal value of the child node of the father node attribute type of the attribute of class;
Meanwhile if there are also junior's child nodes below the child node of the father node, saved the child node of the father node as father Point, and repeat above-mentioned typesetting operation;
After completing typesetting operation, typesetting result is obtained.
5. a kind of method that JSON file is converted to dll file according to claim 1, it is characterised in that: the step Rapid S5 is specifically included:
Step S51, according to the type information of class, compiler object is created;
Step S52, it according to the reference information of class, creates and compiling parameter object is set;
Step S53, according to specified storing path, DLL object is created, typesetting result is generated into dll file and is protected to realize It is stored to specified path.
6. a kind of device that JSON file is converted to dll file, it is characterised in that: described device include JSON read module, Format converting module, XML read module, type-setting module and generation module;
The JSON read module, the JSON data format text that manufacturing execution system for receiving input provides;
The format converting module, the XML data format for using JSON data format text conversion at C# programming language Text;
The XML read module, for reading the basic element information in XML data format text, the basic element information Include the data information for generating class;
The type-setting module for data information to be carried out typesetting according to the typesetting format of class, and obtains typesetting result;
The generation module for calling the function library in C# programming language that typesetting result is generated dll file, and is saved in Specified path.
7. a kind of device that JSON file is converted to dll file according to claim 6, it is characterised in that: the lattice Formula conversion module specifically:
The XML data for being used JSON data format text conversion at C# programming language using Newtonsoft.Json function library Format text, and obtain XML data format text results.
8. a kind of device that JSON file is converted to dll file according to claim 6, it is characterised in that: the XML Read module specifically:
The basic element information in XML data format text is read using the function library traversal in C# programming language, it is described basic Element information includes the data information for generating class;
Wherein, the basic element information read in XML data format text specifically includes:
The Property Name information for generating class is read, the Property Name information is located at the section of the XML data format text In point information;
The attribute type information for generating class is read, the attribute type information is located at the nodal value of the XML data format In;
The composed structure information for generating class is read, the composed structure information is located at the father node of the XML data format In information, and the data information in a father node is for generating a class text.
9. a kind of device that JSON file is converted to dll file according to claim 6, it is characterised in that: the row Version module specifically:
All data informations that traversal is read out carry out typesetting according to the typesetting format of class, and specific typesetting operation includes: by father As the title of class after the initial caps of the nodename of node, by the initial of the nodename of the child node of the father node As the attribute of class after capitalization, and judge according to the nodal value of the child node of the father node attribute type of the attribute of class;
Meanwhile if there are also junior's child nodes below the child node of the father node, saved the child node of the father node as father Point, and repeat above-mentioned typesetting operation;
After completing typesetting operation, typesetting result is obtained.
10. a kind of device that JSON file is converted to dll file according to claim 6, it is characterised in that: the life Compiler-creating unit, parameter set unit and result generation unit are specifically included at module;
The compiler-creating unit creates compiler object for the type information according to class;
The parameter set unit creates for the reference information according to class and compiling parameter object is arranged;
The result generation unit, for creating DLL object according to specified storing path, to realize typesetting result is raw At dll file and it is saved in specified path.
CN201910314155.5A 2019-04-18 2019-04-18 Method and device for converting JSON file into DLL file Active CN110162307B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910314155.5A CN110162307B (en) 2019-04-18 2019-04-18 Method and device for converting JSON file into DLL file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910314155.5A CN110162307B (en) 2019-04-18 2019-04-18 Method and device for converting JSON file into DLL file

Publications (2)

Publication Number Publication Date
CN110162307A true CN110162307A (en) 2019-08-23
CN110162307B CN110162307B (en) 2022-11-11

Family

ID=67639499

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910314155.5A Active CN110162307B (en) 2019-04-18 2019-04-18 Method and device for converting JSON file into DLL file

Country Status (1)

Country Link
CN (1) CN110162307B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101968783A (en) * 2010-09-19 2011-02-09 深圳市万兴软件有限公司 Method and device of converting XML document into Excel document
CN105117378A (en) * 2015-08-05 2015-12-02 联动优势电子商务有限公司 Method and apparatus for converting JSON file into EXCEL file
US20160371339A1 (en) * 2015-06-17 2016-12-22 Qualcomm Incorporated Executing a faceted search within a semi-structured database using a bloom filter
CN108595164A (en) * 2018-04-08 2018-09-28 浙江网盛数新软件股份有限公司 A kind of conversion method of data format and Java object
CN108614808A (en) * 2016-12-12 2018-10-02 北大方正集团有限公司 The composition method and composing device of XML document

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101968783A (en) * 2010-09-19 2011-02-09 深圳市万兴软件有限公司 Method and device of converting XML document into Excel document
US20160371339A1 (en) * 2015-06-17 2016-12-22 Qualcomm Incorporated Executing a faceted search within a semi-structured database using a bloom filter
CN105117378A (en) * 2015-08-05 2015-12-02 联动优势电子商务有限公司 Method and apparatus for converting JSON file into EXCEL file
CN108614808A (en) * 2016-12-12 2018-10-02 北大方正集团有限公司 The composition method and composing device of XML document
CN108595164A (en) * 2018-04-08 2018-09-28 浙江网盛数新软件股份有限公司 A kind of conversion method of data format and Java object

Also Published As

Publication number Publication date
CN110162307B (en) 2022-11-11

Similar Documents

Publication Publication Date Title
Braun et al. A first course in statistical programming with R
Forcier et al. Python web development with Django
CN102117202B (en) J2EE architecture-based code generating device
Moore Python GUI Programming with Tkinter: Develop responsive and powerful GUI applications with Tkinter
Dabbas Interactive Dashboards and Data Apps with Plotly and Dash: Harness the power of a fully fledged frontend web framework in Python–no JavaScript required
Gerasimov et al. Continuous transition from model-driven prototype to full-size real-world enterprise information systems
US10229096B1 (en) Automatic generation of a presentation from code based on analysis of an intermediate version of the code
US8849650B2 (en) System and method for automatically generating sentences of a language
Chadha Improving the usability of App Inventor through conversion between blocks and text
CN110162307A (en) A kind of method and device that JSON file is converted to dll file
US20050177788A1 (en) Text to XML transformer and method
US9477927B2 (en) Automatic test generation for decision table based rules
CN114296726A (en) Code generation method and device, computer equipment and storage medium
Skanda et al. Assessment of Quality of Program Based on Static Analysis
Chou Algorithm education in Python
Boubekeur A Learning Corpus and Feedback Mechanism for a Domain Modeling Assistant
Chang et al. An efficient information system generator
Kim et al. Adapting higher-order list operators for blocks programming
Groner Learning javaScript data structures and algorithms
Moore et al. Python GUI Programming-A Complete Reference Guide: Develop responsive and powerful GUI applications with PyQt and Tkinter
Punch et al. Practice of Computing Using Python, The
Lewis et al. Object-orientation, abstraction, and data structures using Scala
Trivedi User interface implementation of environmental data integration system with React
Ismay et al. Getting Used to r, RStudio, and r Markdown
Chudá et al. Automata simulator

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant