This article mainly introduces the nodejsnpmpackage. json Chinese document. Many of the behaviors described in this document are affected by npm-config (7). For more information, see
Introduction
This document provides all necessary configurations in package. json. It must be a real json object instead of a js object.
node, get their number:
You can then recursively query the child nodes in Java and encapsulate them in the map format.
The child's query is obtained by the father's number:
The first-level node is passed in to start the query until the child is not in the level of the node.
Public List Getinfoemonchild (list
Finally, the Gson Tojson (LISTMAP) is convert
In the development project using AJAX, it is often necessary to return the JSON-formatted string to the front end and parse the front end into a JS object (JSON).
ECMA-262 (E3) did not write the JSON concept into the standard, but fortunately in ECMA-262 (E5) The concept of JSON
Method 1: Use the JS extension method if (typeof s = = 'objectnullreturnreturn /^ (string|number) $/. Test (typeof s)? "'" + S + "' for in O" Arr.push ("'" + i + "':return Method 2: Add a reference to the Json2.js var jsondetail = { Content: " I love Beijing Tian ' an gate", Type: "1" };If we want to convert the
Label:
The principle is to take the middle of the number of milliseconds, and then converted to JS date type Function Changedateformat (val) { if (val! = null) { var date = new Date (parseint ("Val.replace" ("/date", "" "). Replace (")/"," "), 10)); //month 0-11, so +1, month less than 10 o'clock complement 0 var month = Date.getmonth () + 1
JSON returns the
ECMA-262 (E3) did not write the JSON concept to the standard, fortunately the concept of JSON in ECMA-262 (E5) was formally introduced, including the global JSON object and the Tojson method of date.1,eval way to parse, I am afraid this is the earliest way to parse. As follows:Copy CodeThe code is as follows:function Strtojson (str) {var
We must have encountered similar problems during the development process. If we directly pass the array obtained by js to the backend, the backend cannot differentiate the array, because if the js array is two-dimensional, it is like this: 1, zhang San, Li Si, 26
So here we will sort out the solution. Hope to help you
First, convert the array to
We must have encountered similar problems during the development process. If we directly pass the array obtained by JS to the backend, the backend cannot differentiate the array, because if the JS array is two-dimensional, it is like this: 1, zhang San, Li Si, 26
So here we will sort out the solution. Hope to help you
First, convert the array to
(); Request. Open ( ' Get ' , ' Getxml. ashx ' );Request. onreadystatechange = Function (){ If (Request. readystate = 4 Request. Status = 200 ){ VaR Xmldoc = Request. responsexml; VaR Root = Xmldoc.doc umentelement; VaR Elements = Root. getelementsbytagname ( " Person " );Alert (elements. Length ); // 2 // Elements [0]. firstchild references the ID node of the first person
, Json.parse to convert the JSON text to an object varRetval=json.stringify (arr); Resp.end (retval);//Response Object End Response});//Server starts operation listening PortServer.listen ("localhost",function() {Console.log ("Server started operation, listening on port 3000 ...");});Page code:DOCTYPE HTML>HTMLLang= "Utf-8">Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"/>Head> titl
How to convert a multidimensional array of JSON into a multi-dimensional array of JS
PHP Code
JScript Code
$.getjson (".. /php/json.php?parm=arr2 ", function (JSON) {//The middle should be how to write});
The final JS if it is
JScript Co
We must have encountered similar problems during the development process. If we directly pass the array obtained by js to the backend, the backend cannot differentiate the array, because if the js array is two-dimensional, it is like this: 1, zhang San, Li Si, 26. Hope to help you first... SyntaxHighlighter. all ();
We must have encountered similar problems during the development process. If we directly pas
, Json.parse to convert the JSON text to an object varRetval=json.stringify (arr); Resp.end (retval);//Response Object End Response});//Server starts operation listening PortServer.listen ("localhost",function() {Console.log ("Server started operation, listening on port 3000 ...");});Page ANGULARJS Code:DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd ">H
1, the Eval method analysis, I am afraid this is the earliest analytic way. As follows:functionvar json = eval (' (' + str + ') 'return '2, new function form, more strange oh. As follows:functionvar json = (new function ("return" +return3. Use the global JSON object as follows:functionreturnAt present IE8 (S)/FIREFOX3.5+/CHROME4/SAFARI4/OPERA10 has implemented th
converting strings to XML objects on the Java side can use Documenthelper.parsetext (Xmlreturn). Getrootelement ();
In JS there is also a way to convert strings into XML objects, you can use the following functions
function Createxml (str) {if (document.all) {var xmldom=new activexobject ("Microsoft.XMLDOM")XMLDOM.lo
Use Replace to convert the address bar:varUrl= ' https://www.baidu.com/s?ie=utf-8f=8rsv_bp=1rsv_idx=1tn=baiduwd=js%E6%AD%A3%E5%88 %99%e8%a1%a8%e8%be%be%e5%bc%8foq=js%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8f%20konggersv_pq= E63baa94000c303crsv_t=2200eomme0fgnsjlppijbdy2ww1cakuxvt8jce2bif1gxlj%2btzixfz%2batlersv_enter=1 inputt=294rsv_sug3=56rsv_sug1=15rsv_sug7=
1,eval way to parse, I am afraid this is the earliest way to parse. As follows:function Strtojson (str) {var json = eval (' (' + str + ') ');return JSON;}Remember to do not forget the parentheses on both sides of Str.2,new function form, more strange oh. As followsfunction Strtojson (str) {var json = (new Function ("return" + str));return
In work, JavaScript objects need to be converted into strings. Therefore, a method is written using the dojo widget to convert JavaScript objects into strings. The specific implementation is as follows:
Dojo. provide ("jsonobject");
Call the dojo widget written above to convert JS objects to strings, as shown below:
Note: The
When writing Ajax, it is often necessary to parse a string returned from the server. Here we will briefly introduce two formats of characters returned by the server and the parsing methods of Js for them.
I. JSON
JavaScript Object Notation (JavaScript Object Notation) is a string that is combined by declaring objects in Js.JS can define objects as follows:VaR OBJ =
{
ID: 2,
Name: 'n'
};
In this way, the obj
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.