Javascript: Difference between revisions

Jump to navigation Jump to search
2,008 bytes added ,  15 May 2024
m
 
(31 intermediate revisions by the same user not shown)
Line 75: Line 75:


== JSON tools ==
== JSON tools ==
Online services
JSON schema generator
* [http://json.parser.online.fr/ Json Parser Online]
* {{Gd}} [http://www.jsonschema.net/ JSON schema generator]
* [http://www.jsonschema.net/ JSON schema generator] {{Gd}}


Browser extensions
JSON validator
* [https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc JSONView] for {{Chrome}}: beautify the remote JSON file (similar extension: [https://chrome.google.com/webstore/detail/json-formatter/bcjindcccaagfpapjjmafapmmgkkhgoa JSON Formatter])
* {{Gd}} [https://jsonformatter.curiousconcept.com/ JSON Formatter & Validator] 會標示語法錯誤的地方 {{access | date = 2024-05-15}}
* [http://jsonlint.com/ JSONLint - The JSON Validator] {{access | date = 2015-09-08}}
* [https://jsonviewer.stack.hu/ Online JSON Viewer and Formatter] 語法錯誤只會顯示錯誤訊息「JSON error: Invalid JSON variable」{{access | date = 2024-05-15}}


Editor plugins
JSON viewer 通常也包含 validator 功能
* [http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Plugin_Central#J JSON Viewer] [http://nppjsonviewer.sourceforge.net/] for Notepad++
* {{Gd}} [http://www.jsondata.ninja/ JSON Data Ninja] {{access | date = 2017-05-24}}
* [http://www.camdemy.com/media/7427 Sublime Text 套件介紹(四):Pretty JSON]{{access | date=2014-03-11}}
*# 輸入:  文字
*# 可以把 JSON 多筆資料轉成表格格式
*# 有標示某節點下的資料筆數
*# 會將編碼後的中文還原成可讀
 
* [http://json.parser.online.fr/ Json Parser Online] {{access | date = 2017-05-24}}
*# 輸入:  文字
*# 沒有顯示成 Tree 結構,但有美化語法方便閱讀
*# 有標示某節點下的資料筆數
*# 會將編碼後的中文還原成可讀
 
* [http://codebeautify.org/jsonviewer Best Online JSON Viewer, Beautifier, Formatter, Analyser, Minify, Converter] {{access | date = 2017-05-24}}
*# 輸入:  文字
*# Tree Viewer 顯示結構
*# 有標示某節點下的資料筆數
*# <span style="color: #999;">不會將編碼後的中文還原成可讀</span>
 
* [https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc JSONView] for {{Chrome}}: beautify the remote JSON file
*# 輸入: 網址
*# 沒有顯示成 Tree 結構,但有美化語法方便閱讀
*# <span style="color: #999;">沒有標示某節點下的資料筆數</span>
*# 會將編碼後的中文還原成可讀 Unicode/Chinese issue: the garbled Chinese characters will become human readable!
 
* [https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop Postman] for {{Chrome}}. [[HTTP request and response data tool]] {{access | date = 2017-06-09}}  
*# 輸入: 網址
*# 沒有顯示成 Tree 結構,但有美化語法方便閱讀
*# <span style="color: #999;">沒有標示某節點下的資料筆數</span>
*# 會將編碼後的中文還原成可讀
 
* [https://chrome.google.com/webstore/detail/json-formatter/bcjindcccaagfpapjjmafapmmgkkhgoa JSON Formatter]
 
* [http://jsonviewer.codeplex.com/ JSON Viewer]  v. 1.2.0.0 解壓縮直接執行 JsonView\JsonView.exe (免安裝即可執行) {{Win}}
** 大檔 (檔案大小 6MB) 測試: 停頓約半分鐘後,即可使用


standalone
* [https://notepad-plus-plus.org/ Notepad++] v. 6.8.7 + [https://sourceforge.net/projects/nppjsonviewer/ JSONViewer Notepad++ plugin] v.1.22
* [http://jsonviewer.codeplex.com/ JSON Viewer] 解壓縮直接執行 JsonView\JsonView.exe (免安裝即可執行) {{Win}}
** 大檔 (檔案大小 6MB) 測試: 沒有反應超過5分鐘


== performance issue: compression tools, using CDN ==
* [http://youknowone.github.io/VisualJSON/ VisualJSON by youknowone] v. 1.6.0 on {{Mac}}
compression tools
*# 輸入: 網址或文字
* [http://jscompress.com/ Minify Javascript Online / Online JavaScript Packer]
*# 顯示成 Tree 結構
*# 有標示某節點下的資料筆數
*# 會將編碼後的中文還原成可讀




Using CDN(Content Delivery Network)
* ''$'' [http://www.cocoajsoneditor.com/ Cocoa JSON Editor - Powerful JSON String Editor for Developers, API, Endpoints, Rest client] v. 1.2.5 on {{Mac}}
* [https://developers.google.com/speed/libraries/devguide?hl=zh-tw Google Hosted Libraries - Developer's Guide - Make the Web Faster — Google Developers]<ref>[http://blog.longwin.com.tw/2008/11/google-cdn-host-ajax-library-jquery-2008/ 使用 Google CDN Host 的 Javascript Library - jQuery - Tsung's Blog], [http://stackoverflow.com/questions/5206666/jquery-ui-how-to-use-google-cdn javascript - jquery ui - how to use google CDN - Stack Overflow]</ref>
*# 輸入: 文字或檔案
* [http://www.asp.net/ajaxlibrary/cdn.ashx Microsoft Ajax Content Delivery Network - ASP.NET Ajax Library]
*# Tree Viewer 顯示結構
*# 有標示某節點下的資料筆數
*# 會將編碼後的中文還原成可讀


* ''$'' [http://textlab-app.com/ TextLab] v. 1.3.4 on {{Mac}}
*# 輸入: 文字或檔案
*# 沒有顯示成 Tree 結構,但有美化語法方便閱讀
*# <span style="color: #999;">沒有標示某節點下的資料筆數</span>
*# 會將編碼後的中文還原成可讀


<pre>
Other tools
//If the javascript library hosted at CDN was failed to connect, it will switch to local javascript file automatically.
* [https://www.planetoid.info/tools/convert_javascript_array_to_php_array/ Convert JavaScript Array to PHP Array]


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
Editor plugins
<script>!window.jQuery && document.write('<script src="local-js-path/jquery-1.8.3.min.js"><\/script>');</script>
* [http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Plugin_Central#J JSON Viewer] [http://nppjsonviewer.sourceforge.net/] for Notepad++
* [http://www.camdemy.com/media/7427 Sublime Text 套件介紹(四):Pretty JSON]{{access | date=2014-03-11}}


<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js" type="text/javascript"></script>
== Performance issue: compression tools, using CDN ==
<script>!window.jQuery.ui && document.write('<script src="local-js-path/jquery-ui-effects.custom-1.9.2.min.js"><\/script>');</script>
[[Speed up websites#JavaScript part]]
</pre>


== troubleshooting steps ==
== troubleshooting steps ==
Line 116: Line 157:
# [[Check Browser Compatibility | Checking browser compatibility]]
# [[Check Browser Compatibility | Checking browser compatibility]]
# Javascript location: (1)JavaScript in <head> or <body> [http://api.jquery.com/click/ ex: .click()], (2)JavaScript in <input> tag or other DOM elements' tag ex: <button type="button" onclick="myFunction()" id="buttonId">Try it</button><ref>[http://www.w3schools.com/js/js_howto.asp JavaScript How To]</ref>
# Javascript location: (1)JavaScript in <head> or <body> [http://api.jquery.com/click/ ex: .click()], (2)JavaScript in <input> tag or other DOM elements' tag ex: <button type="button" onclick="myFunction()" id="buttonId">Try it</button><ref>[http://www.w3schools.com/js/js_howto.asp JavaScript How To]</ref>
=== jsfiddle:Uncaught ReferenceError: function_name is not defined ===
message: Uncaught ReferenceError: function_name is not defined
* possibile solution: settings - '''No wrap - in <body>''' or '''No wrap - in <head>'''




more on [[Javascript debug]]
more on [[Javascript debug]]


== references ==
== References ==
<references/>
<references/>
== Further reading ==
# [http://technet.microsoft.com/library/ee198686.aspx Microsoft - Scripting Guidelines]


[[Category:Programming]]
[[Category:Programming]]
[[Category:Web_Dev]]
[[Category:Web_Dev]]
[[Category:Javascript]]
[[Category:Javascript]]
[[Category:WebDesign]]
[[Category:Design]]
 
further reading
# [http://technet.microsoft.com/library/ee198686.aspx Microsoft - Scripting Guidelines]

Navigation menu