CN105069116A - Method and system for converting json string into array - Google Patents

Method and system for converting json string into array Download PDF

Info

Publication number
CN105069116A
CN105069116A CN201510489962.2A CN201510489962A CN105069116A CN 105069116 A CN105069116 A CN 105069116A CN 201510489962 A CN201510489962 A CN 201510489962A CN 105069116 A CN105069116 A CN 105069116A
Authority
CN
China
Prior art keywords
array
json form
format
character string
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.)
Pending
Application number
CN201510489962.2A
Other languages
Chinese (zh)
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.)
Beijing Si Tech Information Technology Co Ltd
Original Assignee
Beijing Si Tech Information Technology 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 Beijing Si Tech Information Technology Co Ltd filed Critical Beijing Si Tech Information Technology Co Ltd
Priority to CN201510489962.2A priority Critical patent/CN105069116A/en
Publication of CN105069116A publication Critical patent/CN105069116A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/80Information retrieval; Database structures therefor; File system structures therefor of semi-structured data, e.g. markup language structured data such as SGML, XML or HTML
    • G06F16/84Mapping; Conversion

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The invention relates to a method and system for converting a character string with a json format into an array. The method comprises the following steps of: acquiring a to-be-converted character string with the json format; defining a document format according to attributes of a json object corresponding to a target array; and performing format conversion on the character string with the json format according to the defined document format to obtain the target array. The method is convenient to operate without many times of code writing for data conversion; the method is simple; and redundancy codes are greatly reduced. Simple and efficient code requirements are met.

Description

A kind of method and system json string being converted into array
Technical field
The present invention relates to internet web development field, particularly a kind of method and system json string being converted into array.
Background technology
The develop rapidly of current internet, the changes in demand of the network user is not only fast but also large, and subtle, how to transmit data between platform, which type of format transmission to become user pays close attention to.How many publicity have cross-platform about XML, across the advantage of language, but: unless be applied to WebServices, otherwise in common Web applies, developer be often that saturating brains have been hindered in the parsing of XML, no matter be that server end generates or processing XML, or client JavaScript analyzing XML, all usually causes complicated code, extremely low development efficiency.In fact, for most of Web application, they do not need complicated XML to transmit data, and the extendability of XML seldom has advantage, and many AJAX application even directly return HTML fragment to build Creating Dynamic Web Pages.Compare with returning XML and resolving it, return the complicacy that HTML fragment greatly reduces system, but lacked certain dirigibility simultaneously.The appearance of JSON can be described as the demand in order to meet this respect.Conveniently easily be integrated in html page to meet the requirement of Ajax.Along with the use of JSON is increasingly extensive, the conversion for JSON and other data layout also becomes a hot technology.
Summary of the invention
Technical matters to be solved by this invention is to provide a kind of method and system json form being rapidly converted into array.
The technical scheme that the present invention solves the problems of the technologies described above is as follows: a kind of character string by json form is converted into the method for array, comprises the following steps:
Obtain the character string of json form to be transformed;
Attribute according to the json object corresponding with target array defines document format;
The character string of described json form is carried out format conversion according to the document format of definition, obtains target array.
The invention has the beneficial effects as follows: simple operation of the present invention, avoid and repeatedly write the conversion that code carries out data, and short and sweet, greatly reduce redundant code.Meet and simplify efficient code calls.
On the basis of technique scheme, the present invention can also do following improvement.
Further, the described array according to described json form and document format carry out conversion and are specially: call format transfer tool, carry out format conversion according to the array of described json form and document format.
Further, described format conversion instrument adopts following methods to carry out format conversion:
Obtain the length of the array of json form;
Obtain the length of document format;
Obtain major key and the key assignments of json form;
Embedded process is carried out to document format;
According to the length of the array of json form, the length of document format, the major key of json form and key assignments with nested after document format carry out repeatedly format conversion.
Further, target array is shown.
Further, a kind of character string by json form is converted into the system of array, comprises acquisition module, definition module and conversion module;
Described acquisition module, for obtaining the character string of json form to be transformed;
Described definition module, for defining document format according to the attribute of the json object corresponding with target array;
Described conversion module, for the character string of described json form is carried out format conversion according to the document format of definition, obtains target array.
Further, described conversion module is specially: call format transfer tool, carry out format conversion according to the array of described json form and document format.
Further, described format conversion instrument is specifically for the length that obtains the array of json form; Obtain the length of document format; Obtain major key and the key assignments of json form; Embedded process is carried out to document format; According to the length of the array of json form, the length of document format, the major key of json form and key assignments with nested after document format carry out repeatedly format conversion.
Further, also comprise: display module, for target array is shown.
Accompanying drawing explanation
Fig. 1 is the inventive method flow chart of steps;
Fig. 2 is present system structural drawing.
In accompanying drawing, the list of parts representated by each label is as follows:
1, acquisition module, 2, definition module, 3, conversion module, 4, display module.
Embodiment
Be described principle of the present invention and feature below in conjunction with accompanying drawing, example, only for explaining the present invention, is not intended to limit scope of the present invention.
Embodiment 1
As shown in Figure 1, a kind of character string by json form is converted into the method for array, comprises the following steps:
Obtain the character string of json form to be transformed;
Document format (i.e. SCHEMA) is defined according to the attribute of the json object corresponding with target array;
The character string of described json form is carried out format conversion according to the document format of definition, obtains target array.
The described array according to described json form and document format carry out conversion and are specially: call format transfer tool, carry out format conversion according to the array of described json form and document format.
Described format conversion instrument adopts following methods to carry out format conversion:
Obtain the length of the array of json form;
Obtain the length of document format;
Obtain major key and the key assignments of json form;
Embedded process is carried out to document format;
According to the length of the array of json form, the length of document format, the major key of json form and key assignments with nested after document format carry out repeatedly format conversion.
Target array is shown.
As shown in Figure 2, a kind of character string by json form is converted into the system of array, comprises acquisition module 1, definition module 2 and conversion module 3;
Described acquisition module 1, for obtaining the character string of json form to be transformed;
Described definition module 2, for defining document format according to the attribute of the json object corresponding with target array;
Described conversion module 3, for the character string of described json form is carried out format conversion according to the document format of definition, obtains target array.
Described conversion module 3 is specially: call format transfer tool, carry out format conversion according to the array of described json form and document format.
Described format conversion instrument is specifically for the length that obtains the array of json form; Obtain the length of document format; Obtain major key and the key assignments of json form; Embedded process is carried out to document format; According to the length of the array of json form, the length of document format, the major key of json form and key assignments with nested after document format carry out repeatedly format conversion.
Also comprise: display module 4, for target array is shown.
1., in concrete enforcement, introduce transfer tool (invention) in the project;
2. the JSON form array will changed according to the actual requirements is ready to;
3. definition will obtain the SCHHEMA of the JSON object properties of array, and can carry out the conversion of complicated JSON object, this depends on the complexity of JSON data Layer level structure;
4. ready JSON string and the SCHEMA that corresponds to JSON are passed to transfer tool, perform transfer tool.
Obtain net result, according to expection, the array data after conversion is shown to interface.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.

Claims (8)

1. the character string of json form is converted into a method for array, it is characterized in that, comprise the following steps:
Obtain the character string of json form to be transformed;
Attribute according to the json object corresponding with target array defines document format;
The character string of described json form is carried out format conversion according to the document format of definition, obtains target array.
2. the character string by json form according to claim 1 is converted into the method for array, it is characterized in that, the described array according to described json form and document format carry out conversion and are specially: call format transfer tool, carry out format conversion according to the array of described json form and document format.
3. the character string by json form according to claim 2 is converted into the method for array, it is characterized in that, described format conversion instrument adopts following methods to carry out format conversion:
Obtain the length of the array of json form;
Obtain the length of document format;
Obtain major key and the key assignments of json form;
Embedded process is carried out to document format;
According to the length of the array of json form, the length of document format, the major key of json form and key assignments with nested after document format carry out repeatedly format conversion.
4. the character string by json form according to claim 1 is converted into the method for array, it is characterized in that, target array is shown.
5. the character string of json form is converted into a system for array, it is characterized in that, comprise acquisition module (1), definition module (2) and conversion module (3);
Described acquisition module (1), for obtaining the character string of json form to be transformed;
Described definition module (2), for defining document format according to the attribute of the json object corresponding with target array;
Described conversion module (3), for the character string of described json form is carried out format conversion according to the document format of definition, obtains target array.
6. the character string by json form according to claim 5 is converted into the system of array, it is characterized in that, described conversion module (3) is specially: call format transfer tool, carry out format conversion according to the array of described json form and document format.
7. the character string by json form according to claim 6 is converted into the system of array, it is characterized in that,
Described format conversion instrument is specifically for the length that obtains the array of json form; Obtain the length of document format; Obtain major key and the key assignments of json form; Embedded process is carried out to document format; According to the length of the array of json form, the length of document format, the major key of json form and key assignments with nested after document format carry out repeatedly format conversion.
8. the character string by json form according to claim 5 is converted into the system of array, it is characterized in that, also comprises: display module (4), for target array being shown.
CN201510489962.2A 2015-08-11 2015-08-11 Method and system for converting json string into array Pending CN105069116A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510489962.2A CN105069116A (en) 2015-08-11 2015-08-11 Method and system for converting json string into array

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510489962.2A CN105069116A (en) 2015-08-11 2015-08-11 Method and system for converting json string into array

Publications (1)

Publication Number Publication Date
CN105069116A true CN105069116A (en) 2015-11-18

Family

ID=54498486

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510489962.2A Pending CN105069116A (en) 2015-08-11 2015-08-11 Method and system for converting json string into array

Country Status (1)

Country Link
CN (1) CN105069116A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105677803A (en) * 2015-12-31 2016-06-15 清华大学 JSON format setting method of hydrological time series data
CN105808262A (en) * 2016-03-11 2016-07-27 浙江工业大学 Json format data-based naming matching method
CN105868167A (en) * 2016-03-11 2016-08-17 浙江工业大学 Naming resolution method for multiple layers of nested json data
CN110032360A (en) * 2019-04-19 2019-07-19 成都四方伟业软件股份有限公司 Flow of transactions creation method, device and server
CN111045685A (en) * 2019-11-05 2020-04-21 贝壳技术有限公司 Code conversion method, device, storage medium and electronic equipment
CN116011404A (en) * 2022-08-17 2023-04-25 深圳市沃享科技有限公司 Json file reading and writing method based on simplified data format

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073688A (en) * 2010-12-21 2011-05-25 上海容恒信息科技有限公司 Device for converting client form to Web page and method thereof
CN103970737A (en) * 2013-01-24 2014-08-06 腾讯科技(深圳)有限公司 Data constitution method and device
CN104410667A (en) * 2014-10-31 2015-03-11 北京思特奇信息技术股份有限公司 Method and system for conversion from XML message to JSON message

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073688A (en) * 2010-12-21 2011-05-25 上海容恒信息科技有限公司 Device for converting client form to Web page and method thereof
CN103970737A (en) * 2013-01-24 2014-08-06 腾讯科技(深圳)有限公司 Data constitution method and device
CN104410667A (en) * 2014-10-31 2015-03-11 北京思特奇信息技术股份有限公司 Method and system for conversion from XML message to JSON message

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
HENRY_XU: "json学习之三:JSONArray的应用", 《博客园HTTP://WWW.CNBLOGS.COM/HENRYXU/ARCHIVE/2013/03/10/2952738.HTML》 *
邢益良等: "《PHP Web和Android开发入门与实践》", 31 August 2014, 清华大学出版社 *

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105677803A (en) * 2015-12-31 2016-06-15 清华大学 JSON format setting method of hydrological time series data
CN105677803B (en) * 2015-12-31 2019-07-02 清华大学 The JSON format setting method of hydrology time series data
CN105808262A (en) * 2016-03-11 2016-07-27 浙江工业大学 Json format data-based naming matching method
CN105868167A (en) * 2016-03-11 2016-08-17 浙江工业大学 Naming resolution method for multiple layers of nested json data
CN105868167B (en) * 2016-03-11 2018-09-07 浙江工业大学 A kind of Naming resolution method of the json formatted datas of multilayer nest
CN105808262B (en) * 2016-03-11 2018-10-19 浙江工业大学 A kind of name matching process based on json formatted datas
CN110032360A (en) * 2019-04-19 2019-07-19 成都四方伟业软件股份有限公司 Flow of transactions creation method, device and server
CN111045685A (en) * 2019-11-05 2020-04-21 贝壳技术有限公司 Code conversion method, device, storage medium and electronic equipment
CN116011404A (en) * 2022-08-17 2023-04-25 深圳市沃享科技有限公司 Json file reading and writing method based on simplified data format

Similar Documents

Publication Publication Date Title
CN105069116A (en) Method and system for converting json string into array
CN104461484B (en) The implementation method and device of front-end template
Wang Improving data transmission in web applications via the translation between XML and JSON
CN105824787B (en) A kind of control method and system of html template dynamic configuration
CN106293675B (en) System static resource loading method and device
CN105447099A (en) Log structured information extraction method and apparatus
CN1392986A (en) Method and apparatus for generating documents for various presentations
CN106445484A (en) Method and system for realizing data tracking through software development kit
CN103389895A (en) Method and system for generating front end page
CN104361081A (en) WEB document-based automatic abstracting method
CN103309806B (en) The device and method of a kind of quick development and testing
CN102741811A (en) Improving performance of template based JavaScript widgets
CN102982010A (en) Method and device for abstracting document structure
CN103970750A (en) Method and device for generating HTML (Hypertext Markup Language) web pages
CN102479248A (en) Method and system for carrying out structured processing on electronic document
US20150220236A1 (en) Post-designing method and apparatus based on variant configuration in development of graphic user interface
CN104951311A (en) Page making method and device
CN102073662B (en) Method and system for analyzing and creating XML (Extensible Markup Language) data
US10742764B2 (en) Web page generation system
EP2874071A1 (en) Method of implementing structured and non-structured data in xml document
CN116521621A (en) Data processing method and device, electronic equipment and storage medium
CN102063415B (en) Method and system for embedding single-byte fonts in PDF (Portable Document Format) file
CN103885765A (en) Method for coding XBRL (extensible business reporting language) elements
CN105338104A (en) Business request responding method, analysis method and analysis system
CN113139145B (en) Page generation method and device, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20151118

RJ01 Rejection of invention patent application after publication