It is recommended to view the "most convenient" method of Json output.

Source: Internet
Author: User
Tags jsonviewer fiddler2

The presentation layer of the project uses MVC + Extjs. During the development process, once the page is not displayed normally, the first one that needs to be checked is always "does Action output correct Json ?". Because developers perform this operation frequently on a daily basis, our goal is to find a method that does not require additional effort to view Json output at any time.

"No extra effort required" means that when you need to view the Json output, you only need to turn your eyes around (you may need to at least two more mouse clicks, I'm afraid) you can quickly find the desired result.

There are many ways to view Json output. The solution we can find is "Fiddler2 + JsonViewer plug-in + custom Fiddler2 filter condition ". To view the Json output, you only need to run Fiddler first and then operate the Web page normally in the browser. Then, you can see the intercepted Json output in Fiddler, as shown in.

Install the Fiddler2 + JsonViewer plug-in

Fiddler2 is an old Web debugging tool. After the download and installation, click Start | program | Fiddler2 or choose tools | Fiddler2 from the IE menu to run the tool, it automatically registers itself as the proxy server of IE to intercept any requests/responses that pass through IE. When it is disabled, it will automatically cancel the proxy server configuration (You have to add the proxy server configuration yourself when using Fiddler1 that year, which is very troublesome to say ).
JsonViewer is a small tool for viewing Json objects. After decompression, You can see three subdirectories:
-JsonView: runs independently.
-Visualizer: VS2005 plug-in.
-Fiddler: The Fiddler2 plug-in.
We will install the Fiddler2 plug-in of JsonViewer. By copying all the files in the Fiddler directory to the "install directory \ Inspectors \" of fiddler2 \". Then modify "install directory \ fiddler.exe. config of Fiddler2", as shown in. The bold part is the configuration information that needs to be added.

Copy to ClipboardReference: www.bkjia.comw.fiddler.exe. config
<Configuration>
<Runtime>
<GeneratePublisherEvidence enabled = "false"/>
<AssemblyBinding xmlns = "urn: schemas-microsoft-com: asm. v1">
<Probing privatePath = "Inspectors"/>
</AssemblyBinding>
</Runtime>
</Configuration>


Note that IE7 and. NET Framework are hardcoded as long as they are requests to localhost, they do not pass through the proxy server. Therefore, requests such as "http: // localhost: 8000/Default. aspx" will not be intercepted by fiddler2. Solution: 1) Replace "localhost" with "localhost. ", such as" http: // localhost.: 8000/Default. aspx "; 2) Replace" localhost "with the IP address of the cost server, for example," http: // 172.16.75.78: 8000/Default. aspx ".

Now, let's run Fiddler2 and click the page to view a large number of requests/responses in the "Web Sessions" list on the left side of the Fiddler2 form. Click the one that returns Json, and then click the "Inspectors" and "Json" Tab pages on the right. However, by default, Fiddler2 will display all requests/responses that pass through IE. As a result, there are too many things in the "Web Sessions" list, can I filter out all the items irrelevant to Json? This is not difficult. You only need to add a few lines of code in "mrmrules" of Fiddler2.

Custom filter conditions

Click "Rules | Customize Rules..." in the menu of Fiddler2. The code file that can add custom Rules is automatically opened in notepad.
Add the following code in line 1 to add a menu item "show Json only" in the Rules menu of Fiddler2:

Copy to ClipboardReference: [www.bkjia.com] // jcl20091121
Public static RulesOption ("show only & Json ")
Var m_ShowJsonOnly: boolean = false;

Add the following code to the OnBeforeResponse event, which means that if the "Rules | display only Json" menu item is selected, all Content-types will be filtered out! = "Application/json; charset = UTF-8.

Copy to ClipboardReference: [www.bkjia.com] // jcl: 2009-11-21
If (m_ShowJsonOnly ){
// MessageBox. Show (oSession. oResponse. headers. Item ("Content-Type"). ToString ());
If (! OSession. oResponse. headers. ExistsAndContains ("Content-Type", "application/json; charset = UTF-8 ")){
OSession ["ui-hide"] = "hide"; // String value not important
}
}

Article from: http://www.cnblogs.com/1-2-3/

  • 2 pages in total:
  • Previous Page
  • 1
  • 2
  • Next Page

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.