Permalink
Browse files

added iOS and Android support

  • Loading branch information...
1 parent b384a61 commit 19d216cc8b297e4967db0f0248c16e9bde45e457 @anujb anujb committed Jun 16, 2013
Showing with 1,588 additions and 61 deletions.
  1. +1 −0 Components/json.net-4.5.11.info
  2. BIN Components/json.net-4.5.11.png
  3. +47 −0 Components/json.net-4.5.11/component/Details.md
  4. +27 −0 Components/json.net-4.5.11/component/GettingStarted.md
  5. +1 −0 Components/json.net-4.5.11/component/License.md
  6. +18 −0 Components/json.net-4.5.11/component/Manifest.xml
  7. BIN Components/json.net-4.5.11/component/icons/json.net_128x128.png
  8. BIN Components/json.net-4.5.11/component/icons/json.net_512x512.png
  9. BIN Components/json.net-4.5.11/lib/android/Newtonsoft.Json.dll
  10. BIN Components/json.net-4.5.11/lib/ios/Newtonsoft.Json.dll
  11. +19 −0 Components/json.net-4.5.11/samples/Json.NET.Android.Sample/Assets/AboutAssets.txt
  12. +77 −0 Components/json.net-4.5.11/samples/Json.NET.Android.Sample/Json.NET.Android.Sample.csproj
  13. +22 −0 Components/json.net-4.5.11/samples/Json.NET.Android.Sample/Json.NET.Android.Sample.sln
  14. +50 −0 Components/json.net-4.5.11/samples/Json.NET.Android.Sample/MainActivity.cs
  15. +41 −0 Components/json.net-4.5.11/samples/Json.NET.Android.Sample/Properties/AssemblyInfo.cs
  16. +44 −0 Components/json.net-4.5.11/samples/Json.NET.Android.Sample/Resources/AboutResources.txt
  17. BIN Components/json.net-4.5.11/samples/Json.NET.Android.Sample/Resources/Drawable/Icon.png
  18. +23 −0 Components/json.net-4.5.11/samples/Json.NET.Android.Sample/Resources/Layout/Main.axml
  19. +88 −0 Components/json.net-4.5.11/samples/Json.NET.Android.Sample/Resources/Resource.Designer.cs
  20. +5 −0 Components/json.net-4.5.11/samples/Json.NET.Android.Sample/Resources/Values/Strings.xml
  21. +39 −0 Components/json.net-4.5.11/samples/Json.NET.iOS.Sample/AppDelegate.cs
  22. BIN Components/json.net-4.5.11/samples/Json.NET.iOS.Sample/Default-568h@2x.png
  23. +14 −0 Components/json.net-4.5.11/samples/Json.NET.iOS.Sample/Info.plist
  24. +108 −0 Components/json.net-4.5.11/samples/Json.NET.iOS.Sample/Json.NET iOS Sample.csproj
  25. +32 −0 Components/json.net-4.5.11/samples/Json.NET.iOS.Sample/Json.NET.iOS.Sample.sln
  26. +20 −0 Components/json.net-4.5.11/samples/Json.NET.iOS.Sample/Main.cs
  27. +49 −0 Components/json.net-4.5.11/samples/Json.NET.iOS.Sample/SampleViewController.cs
  28. +36 −0 Components/json.net-4.5.11/samples/Json.NET.iOS.Sample/SampleViewController.designer.cs
  29. +285 −0 Components/json.net-4.5.11/samples/Json.NET.iOS.Sample/SampleViewController.xib
  30. +174 −0 Divan.Android/Divan.Robot.csproj
  31. +44 −0 Divan.Android/Resources/AboutResources.txt
  32. +57 −0 Divan.Android/Resources/Resource.designer.cs
  33. +4 −0 Divan.Android/Resources/values/Strings.xml
  34. +164 −0 Divan.iOS/Divan.iOS.csproj
  35. +12 −6 Divan.sln
  36. +6 −0 src/CouchDatabase.cs
  37. +74 −54 src/CouchDesignDocument.cs
  38. +7 −1 src/ICouchDatabase.cs
@@ -0,0 +1 @@
+{"Name":"Json.NET","Id":42,"Alias":"json.net","Description":"Json.NET is a high-performance JSON framework.\n\n## Features\n\n - Flexible JSON serializer for converting between .NET objects and JSON\n - LINQ to JSON for manually reading and writing JSON\n - High performance, faster than .NET\u0027s built-in JSON serializers\n - Write indented, easy to read JSON\n - Convert JSON to and from XML\n\nFor simple conversions to and from JSON strings and .NET objects,\nJsonConvert provides the SerializeObject and DeserializeObject methods.\n\n```csharp\nusing Newtonsoft.Json;\n...\n\npublic class Person\n{\n public string Name { get; set; }\n public DateTime Birthday { get; set; }\n}\n\nvoid PersonToJsonToPersonExample ()\n{\n var person = new Person { Name = \"Bob\", Birthday = new DateTime (1987, 2, 2) };\n var json = JsonConvert.SerializeObject (person);\n Console.WriteLine (\"JSON representation of person: {0}\", json);\n var person2 = JsonConvert.DeserializeObject\u003cPerson\u003e (json);\n Console.WriteLine (\"{0} - {1}\", person2.Name, person2.Birthday);\n}\n```\n\nFor dealing with JSON data in more direct form, without mapping them to C# classes, use LINQ to JSON:\n\n```csharp\nusing Newtonsoft.Json.Linq;\n...\n\nvoid LinqExample ()\n{\n string json = @\"{ Name: \u0027Bob\u0027, HairColor: \u0027Brown\u0027 }\";\n var bob = JObject.Parse (json);\n \n Console.WriteLine (\"{0} with {1} hair\", bob[\"Name\"], bob[\"HairColor\"]);\n}\n```\n","Version":"4.5.11","Summary":"A high-performance JSON framework for .NET.","QuickStart":"For simple conversions to and from JSON strings and .NET objects,\nJsonConvert provides the SerializeObject and DeserializeObject methods.\n\n```csharp\npublic class Person\n{\n\tpublic string Name { get; set; }\n\tpublic DateTime Birthday { get; set; }\n}\n\nPerson person = new Person { Name = \"Bob\", Birthday = new DateTime (1987, 2, 2) };\nstring output = Newtonsoft.Json.JsonConvert.SerializeObject (person);\nConsole.WriteLine (output);\nConsole.WriteLine();\n\nperson = Newtonsoft.Json.JsonConvert.DeserializeObject\u003cPerson\u003e (output);\nConsole.WriteLine (\"{0} - {1}\", person.Name, person.Birthday);\n```\n\nFor dealing with JSON objects in more direct form, there\u0027s LINQ to JSON:\n\n```csharp\nstring json = @\"{ Name: \u0027Bob\u0027, HairColor: \u0027Brown\u0027 }\";\nvar bob = Newtonsoft.Json.Linq.JObject.Parse (json);\n\nConsole.WriteLine (\"{0} with {1} hair\", (string)bob[\"Name\"], (string)bob[\"HairColor\"]);\n```","Hash":"4819d5786e4bca48bbd4cd5c3e03f0d8","TargetPlatforms":["ios","android"]}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,47 @@
+Json.NET is a high-performance JSON framework.
+
+## Features
+
+ - Flexible JSON serializer for converting between .NET objects and JSON
+ - LINQ to JSON for manually reading and writing JSON
+ - High performance, faster than .NET's built-in JSON serializers
+ - Write indented, easy to read JSON
+ - Convert JSON to and from XML
+
+For simple conversions to and from JSON strings and .NET objects,
+JsonConvert provides the SerializeObject and DeserializeObject methods.
+
+```csharp
+using Newtonsoft.Json;
+...
+
+public class Person
+{
+ public string Name { get; set; }
+ public DateTime Birthday { get; set; }
+}
+
+void PersonToJsonToPersonExample ()
+{
+ var person = new Person { Name = "Bob", Birthday = new DateTime (1987, 2, 2) };
+ var json = JsonConvert.SerializeObject (person);
+ Console.WriteLine ("JSON representation of person: {0}", json);
+ var person2 = JsonConvert.DeserializeObject<Person> (json);
+ Console.WriteLine ("{0} - {1}", person2.Name, person2.Birthday);
+}
+```
+
+For dealing with JSON data in more direct form, without mapping them to C# classes, use LINQ to JSON:
+
+```csharp
+using Newtonsoft.Json.Linq;
+...
+
+void LinqExample ()
+{
+ string json = @"{ Name: 'Bob', HairColor: 'Brown' }";
+ var bob = JObject.Parse (json);
+
+ Console.WriteLine ("{0} with {1} hair", bob["Name"], bob["HairColor"]);
+}
+```
@@ -0,0 +1,27 @@
+For simple conversions to and from JSON strings and .NET objects,
+JsonConvert provides the SerializeObject and DeserializeObject methods.
+
+```csharp
+public class Person
+{
+ public string Name { get; set; }
+ public DateTime Birthday { get; set; }
+}
+
+Person person = new Person { Name = "Bob", Birthday = new DateTime (1987, 2, 2) };
+string output = Newtonsoft.Json.JsonConvert.SerializeObject (person);
+Console.WriteLine (output);
+Console.WriteLine();
+
+person = Newtonsoft.Json.JsonConvert.DeserializeObject<Person> (output);
+Console.WriteLine ("{0} - {1}", person.Name, person.Birthday);
+```
+
+For dealing with JSON objects in more direct form, there's LINQ to JSON:
+
+```csharp
+string json = @"{ Name: 'Bob', HairColor: 'Brown' }";
+var bob = Newtonsoft.Json.Linq.JObject.Parse (json);
+
+Console.WriteLine ("{0} with {1} hair", (string)bob["Name"], (string)bob["HairColor"]);
+```
@@ -0,0 +1 @@
+# The MIT License (MIT)Copyright (c) 2007 James Newton-KingPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<component format="1" id="json.net">
+ <name>Json.NET</name>
+ <publisher>James Newton-King</publisher>
+ <publisher-url>http://james.newtonking.com/projects/json-net.aspx</publisher-url>
+ <version>4.5.11</version>
+ <summary>A high-performance JSON framework for .NET.</summary>
+ <samples>
+ <sample id="Json.NET.Android.Sample">
+ <name>Android Sample.</name>
+ <summary>Android Sample</summary>
+ </sample>
+ <sample id="Json.NET.iOS.Sample">
+ <name>iOS Sample.</name>
+ <summary>iOS Sample</summary>
+ </sample>
+ </samples>
+</component>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,19 @@
+Any raw assets you want to be deployed with your application can be placed in
+this directory (and child directories) and given a Build Action of "AndroidAsset".
+
+These files will be deployed with you package and will be accessible using Android's
+AssetManager, like this:
+
+public class ReadAsset : Activity
+{
+ protected override void OnCreate (Bundle bundle)
+ {
+ base.OnCreate (bundle);
+
+ InputStream input = Assets.Open ("my_asset.txt");
+ }
+}
+
+Additionally, some Android functions will automatically load asset files:
+
+Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{A15E29B4-3BA6-4946-AD78-B8AFDC09884D}</ProjectGuid>
+ <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Json.NET.Android.Sample</RootNamespace>
+ <AssemblyName>Json.NET.Android.Sample</AssemblyName>
+ <FileAlignment>512</FileAlignment>
+ <AndroidApplication>true</AndroidApplication>
+ <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
+ <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
+ <AndroidLinkMode>None</AndroidLinkMode>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
+ <AndroidLinkMode>SdkOnly</AndroidLinkMode>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Mono.Android" />
+ <Reference Include="mscorlib" />
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Xml" />
+ <Reference Include="Newtonsoft.Json">
+ <HintPath>../../lib\/android/Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="MainActivity.cs" />
+ <Compile Include="Resources\Resource.Designer.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Resources\AboutResources.txt" />
+ <None Include="Assets\AboutAssets.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <AndroidResource Include="Resources\Layout\Main.axml" />
+ </ItemGroup>
+ <ItemGroup>
+ <AndroidResource Include="Resources\Values\Strings.xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <AndroidResource Include="Resources\Drawable\Icon.png" />
+ </ItemGroup>
+ <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Json.NET.Android.Sample", "Json.NET.Android.Sample.csproj", "{A15E29B4-3BA6-4946-AD78-B8AFDC09884D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A15E29B4-3BA6-4946-AD78-B8AFDC09884D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A15E29B4-3BA6-4946-AD78-B8AFDC09884D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A15E29B4-3BA6-4946-AD78-B8AFDC09884D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
+ {A15E29B4-3BA6-4946-AD78-B8AFDC09884D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A15E29B4-3BA6-4946-AD78-B8AFDC09884D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A15E29B4-3BA6-4946-AD78-B8AFDC09884D}.Release|Any CPU.Deploy.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
@@ -0,0 +1,50 @@
+using System;
+using System.Text;
+using Android.App;
+using Android.Widget;
+using Android.OS;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+namespace Json.NET.Android.Sample
+{
+ [Activity(Label = "Json.NET.Android.Sample", MainLauncher = true, Icon = "@drawable/icon")]
+ public class MainActivity : Activity
+ {
+ private EditText json;
+ private TextView output;
+
+ protected override void OnCreate(Bundle bundle)
+ {
+ base.OnCreate (bundle);
+ SetContentView (Resource.Layout.Main);
+
+ FindViewById<Button> (Resource.Id.Parse).Click += OnClickParse;
+ this.json = FindViewById<EditText> (Resource.Id.Json);
+ this.output = FindViewById<TextView> (Resource.Id.Output);
+ }
+
+ private void OnClickParse (object sender, EventArgs eventArgs)
+ {
+ try
+ {
+ JObject obj = JObject.Parse (this.json.Text);
+
+ StringBuilder builder = new StringBuilder();
+ foreach (var kvp in obj)
+ builder.AppendLine (kvp.Key + " = " + kvp.Value);
+
+ this.output.Text = builder.ToString();
+ }
+ catch (FormatException ex)
+ {
+ this.output.Text = ex.ToString();
+ }
+ catch (JsonException ex)
+ {
+ this.output.Text = ex.ToString();
+ }
+ }
+ }
+}
+
@@ -0,0 +1,41 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using Android.App;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Json.NET.Android.Sample")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Json.NET.Android.Sample")]
+[assembly: AssemblyCopyright("Copyright © 2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("a557ce8c-9dbe-4b93-8fc4-95ffc126cf14")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+
+// Add some common permissions, these can be removed if not needed
+[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
+[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
@@ -0,0 +1,44 @@
+Images, layout descriptions, binary blobs and string dictionaries can be included
+in your application as resource files. Various Android APIs are designed to
+operate on the resource IDs instead of dealing with images, strings or binary blobs
+directly.
+
+For example, a sample Android app that contains a user interface layout (Main.xml),
+an internationalization string table (Strings.xml) and some icons (drawable/Icon.png)
+would keep its resources in the "Resources" directory of the application:
+
+Resources/
+ Drawable/
+ Icon.png
+
+ Layout/
+ Main.axml
+
+ Values/
+ Strings.xml
+
+In order to get the build system to recognize Android resources, the build action should be set
+to "AndroidResource". The native Android APIs do not operate directly with filenames, but
+instead operate on resource IDs. When you compile an Android application that uses resources,
+the build system will package the resources for distribution and generate a class called
+"Resource" that contains the tokens for each one of the resources included. For example,
+for the above Resources layout, this is what the Resource class would expose:
+
+public class Resource {
+ public class Drawable {
+ public const int Icon = 0x123;
+ }
+
+ public class Layout {
+ public const int Main = 0x456;
+ }
+
+ public class String {
+ public const int FirstString = 0xabc;
+ public const int SecondString = 0xbcd;
+ }
+}
+
+You would then use Resource.Drawable.Icon to reference the Drawable/Icon.png file, or
+Resource.Layout.Main to reference the Layout/Main.axml file, or Resource.String.FirstString
+to reference the first string in the dictionary file Values/Strings.xml.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+ <EditText
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:id="@+id/Json"
+ android:text="{ &quot;name&quot; : &quot;Foo&quot;, &quot;age&quot;: 22 }"
+ android:singleLine="false"
+ android:lines="7" />
+ <Button
+ android:id="@+id/Parse"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/Parse" />
+ <TextView
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:id="@+id/Output"
+ android:singleLine="false" />
+</LinearLayout>
Oops, something went wrong.

0 comments on commit 19d216c

Please sign in to comment.