Skip to content
Browse files

1) Added Newtonsoft.Json.dll

2) Added some bitmaps used in image lists
3) Added sample grid visualizer
  • Loading branch information...
1 parent 5216ce0 commit f6fe09e3818226a838145b1ed9d817fd1233ec8f Eyal P committed Jun 2, 2007
View
BIN Bin/Newtonsoft.Json.dll
Binary file not shown.
View
4 Fiddler/FiddlerJsonViewer.csproj
@@ -18,15 +18,15 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
- <OutputPath>..\Bin\Fiddler\</OutputPath>
+ <OutputPath>bin\debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
+ <OutputPath>..\Bin\Fiddler\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
View
5 JsonView/JsonView.csproj
@@ -18,18 +18,19 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
- <OutputPath>..\Bin\JsonView\</OutputPath>
+ <OutputPath>bin\debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
+ <OutputPath>..\Bin\JsonView\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
View
15 JsonView/MainForm.cs
@@ -6,6 +6,7 @@
using System.Text;
using System.Windows.Forms;
using EPocalipse.Json.Viewer;
+using System.IO;
namespace EPocalipse.Json.JsonView
{
@@ -19,15 +20,27 @@ public MainForm()
private void MainForm_Shown(object sender, EventArgs e)
{
string[] args = Environment.GetCommandLineArgs();
- foreach (string arg in args)
+ for (int i = 1; i < args.Length; i++)
{
+ string arg = args[i];
if (arg.Equals("/c", StringComparison.OrdinalIgnoreCase))
{
LoadFromClipboard();
}
+ else if (File.Exists(arg))
+ {
+ LoadFromFile(arg);
+ }
}
}
+ private void LoadFromFile(string fileName)
+ {
+ string json = File.ReadAllText(fileName);
+ JsonViewer.ShowTab(Tabs.Viewer);
+ JsonViewer.Json = json;
+ }
+
private void LoadFromClipboard()
{
string json = Clipboard.GetText();
View
61 JsonViewer/GridVisualizer.Designer.cs
@@ -0,0 +1,61 @@
+namespace EPocalipse.Json.Viewer
+{
+ partial class GridVisualizer
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.lvGrid = new System.Windows.Forms.ListView();
+ this.SuspendLayout();
+ //
+ // lvGrid
+ //
+ this.lvGrid.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+ this.lvGrid.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.lvGrid.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
+ this.lvGrid.Location = new System.Drawing.Point(0, 0);
+ this.lvGrid.Name = "lvGrid";
+ this.lvGrid.Size = new System.Drawing.Size(727, 301);
+ this.lvGrid.TabIndex = 0;
+ this.lvGrid.UseCompatibleStateImageBehavior = false;
+ this.lvGrid.View = System.Windows.Forms.View.Details;
+ //
+ // GridVisualizer
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.lvGrid);
+ this.Name = "GridVisualizer";
+ this.Size = new System.Drawing.Size(727, 301);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.ListView lvGrid;
+ }
+}
View
84 JsonViewer/GridVisualizer.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Text;
+using System.Windows.Forms;
+
+namespace EPocalipse.Json.Viewer
+{
+ public partial class GridVisualizer : UserControl, IJsonVisualizer
+ {
+ public GridVisualizer()
+ {
+ InitializeComponent();
+ }
+
+ Control IJsonVisualizer.GetControl(JsonObject jsonObject)
+ {
+ return this;
+ }
+
+ void IJsonVisualizer.Visualize(JsonObject jsonObject)
+ {
+ lvGrid.BeginUpdate();
+ try
+ {
+ lvGrid.Columns.Clear();
+ lvGrid.Items.Clear();
+ FillHeaders(jsonObject.Fields["headers"]);
+ FillRows(jsonObject.Fields["rows"]);
+ }
+ finally
+ {
+ lvGrid.EndUpdate();
+ }
+ }
+
+ private void FillHeaders(JsonObject jsonObject)
+ {
+ foreach (JsonObject header in jsonObject.Fields)
+ {
+ JsonObject nameHeader = header.Fields["name"];
+ if (nameHeader.JsonType == JsonType.Value && nameHeader.Value is string)
+ {
+ string name = (string)nameHeader.Value;
+ lvGrid.Columns.Add(name);
+ }
+ }
+ }
+
+ private void FillRows(JsonObject jsonObject)
+ {
+ string value;
+ foreach (JsonObject row in jsonObject.Fields)
+ {
+ List<string> rowValues = new List<string>();
+ foreach (JsonObject rowValue in row.Fields)
+ {
+ if (rowValue.JsonType == JsonType.Value && rowValue.Value != null)
+ {
+ value = rowValue.Value.ToString();
+ }
+ else
+ value = String.Empty;
+ rowValues.Add(value);
+ }
+ ListViewItem rowItem = new ListViewItem(rowValues.ToArray());
+ lvGrid.Items.Add(rowItem);
+ }
+ }
+
+ string IJsonViewerPlugin.DisplayName
+ {
+ get { return "Grid"; }
+ }
+
+ bool IJsonViewerPlugin.CanVisualize(JsonObject jsonObject)
+ {
+ return jsonObject.ContainsField("headers", JsonType.Array) &&
+ jsonObject.ContainsField("rows", JsonType.Array);
+ }
+ }
+}
View
120 JsonViewer/GridVisualizer.resx
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
View
13 JsonViewer/JsonViewer.cs
@@ -31,7 +31,7 @@ public JsonViewer()
}
catch (Exception e)
{
- MessageBox.Show(String.Format(Resources.ConfigMessage,e.Message), "Json Viewer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ MessageBox.Show(String.Format(Resources.ConfigMessage, e.Message), "Json Viewer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
@@ -271,7 +271,7 @@ private bool IsMatchingNode(TreeNode startNode, string text)
private JsonViewerTreeNode GetRootNode()
{
- if (tvJson.Nodes.Count>0)
+ if (tvJson.Nodes.Count > 0)
return (JsonViewerTreeNode)tvJson.Nodes[0];
return null;
}
@@ -423,7 +423,7 @@ private void ActivateVisualizer()
private void cbVisualizers_SelectedIndexChanged(object sender, EventArgs e)
{
- if (!_updating && GetSelectedTreeNode()!=null)
+ if (!_updating && GetSelectedTreeNode() != null)
{
ActivateVisualizer();
GetSelectedTreeNode().LastVisualizer = (IJsonVisualizer)cbVisualizers.SelectedItem;
@@ -666,8 +666,7 @@ internal bool Initialized
internal void RefreshText()
{
- string text = _jsonObject.Text;
- StringBuilder sb = new StringBuilder(text);
+ StringBuilder sb = new StringBuilder(_jsonObject.Text);
foreach (ICustomTextProvider textVisualizer in _textVisualizers)
{
try
@@ -680,7 +679,9 @@ internal void RefreshText()
//silently ignore
}
}
- this.Text = sb.ToString();
+ string text = sb.ToString();
+ if (text != this.Text)
+ this.Text = text;
}
public IJsonVisualizer LastVisualizer
View
12 JsonViewer/JsonViewer.csproj
@@ -34,7 +34,7 @@
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=1.1.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\..\..\Temp\json\Source\Newtonsoft.Json\bin\Release\Newtonsoft.Json.dll</HintPath>
+ <HintPath>..\Bin\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
@@ -44,6 +44,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="GridVisualizer.cs">
+ <SubType>UserControl</SubType>
+ </Compile>
+ <Compile Include="GridVisualizer.Designer.cs">
+ <DependentUpon>GridVisualizer.cs</DependentUpon>
+ </Compile>
<Compile Include="InternalPlugins.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
@@ -76,6 +82,10 @@
<Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="GridVisualizer.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>GridVisualizer.cs</DependentUpon>
+ </EmbeddedResource>
<EmbeddedResource Include="JsonViewer.resx">
<SubType>Designer</SubType>
<DependentUpon>JsonViewer.cs</DependentUpon>
View
3 JsonViewer/JsonViewer.dll.config
@@ -7,8 +7,9 @@
<plugins>
<add key="default" value="EPocalipse.Json.Viewer.JsonObjectVisualizer, JsonViewer"/>
<add key="AjaxNetDateTime" value="EPocalipse.Json.Viewer.AjaxNetDateTime, JsonViewer"/>
- <!--<add key="Sample" value="EPocalipse.Json.Viewer.Sample, JsonViewer"/>-->
<add key="CustomDate" value="EPocalipse.Json.Viewer.CustomDate, JsonViewer"/>
+ <add key="Grid" value="EPocalipse.Json.Viewer.GridVisualizer, JsonViewer"/>
+ <!--<add key="Sample" value="EPocalipse.Json.Viewer.Sample, JsonViewer"/>-->
</plugins>
</jsonViewer>
</configuration>
View
BIN JsonViewer/array.bmp
Binary file not shown.
View
BIN JsonViewer/btn.bmp
Binary file not shown.
View
BIN JsonViewer/obj.bmp
Binary file not shown.
View
18 Readme.txt
@@ -1,10 +1,10 @@
-The JSON View package is a set of 3 viewers available in the following flavors
+The JSON View package is a set of 3 viewers available in the following flavors:
1) A standalone viewer - JsonView.exe
2) A plugin for Fiddler 2 (http://www.fiddler2.com/) - FiddlerJsonViewer.dll
3) A visualizer for Viusal Studio 2005 - JsonVisualizer.dll
-The viewer supports the notion of plugins to allow you to customize the way JSON object
-are displayed (More info on that at a later stage).
+The viewer supports plugins to allow you to customize the way JSON objects are displayed. Sample plugins
+are provided within the source.
Installation
============
@@ -15,4 +15,14 @@ The archive contains the following directories:
\Visualizer
- To use the standalone viewer, run JsonView.exe from \JsonView
-- To use the Fiddler plugin,
+- To use the Fiddler2 plugin, copy the files from the \Fiddler directory to fiddler's \Inspectors
+ directory and add the following to the <runtime> section of the fiddler.exe.config:
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <probing privatePath="Inspectors" />
+ </assemblyBinding>
+- To use the Visual Studio Visualizer, copy the JsonVisualizer.dll to the Visual Studio Visualizers
+ directory (usually under \My Documents\Visual Studio 2005\Visualizers) and copy the following files
+ to the IDE directory of Visual Studio (Where devenv.exe is located - <Visual Studio>\Common7\IDE):
+ - JsonViewer.dll
+ - JsonViewer.dll.config
+ - Newtonsoft.Json.dll
View
5 Visualizer/JsonVisualizer.csproj
@@ -18,18 +18,19 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
- <OutputPath>..\Bin\Visualizer\</OutputPath>
+ <OutputPath>Bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
+ <OutputPath>..\Bin\Visualizer\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <UseVSHostingProcess>true</UseVSHostingProcess>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.DebuggerVisualizers, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />

0 comments on commit f6fe09e

Please sign in to comment.
Something went wrong with that request. Please try again.