You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2015/05/15 02:33:22 UTC
[1/4] cordova-wp8 git commit: Revert JsonHelper to pre Newtonsoft
implementation
Repository: cordova-wp8
Updated Branches:
refs/heads/master 14b6cc3e8 -> 3ef90c084
Revert JsonHelper to pre Newtonsoft implementation
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/c4498b34
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/c4498b34
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/c4498b34
Branch: refs/heads/master
Commit: c4498b3416e6a368b61a559292a6a08ba0b8f3f8
Parents: f3ce53f
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu May 14 14:46:48 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu May 14 14:46:48 2015 -0700
----------------------------------------------------------------------
template/cordovalib/JSON/JsonHelper.cs | 48 +++++++++++++++++++++++++++--
1 file changed, 45 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/c4498b34/template/cordovalib/JSON/JsonHelper.cs
----------------------------------------------------------------------
diff --git a/template/cordovalib/JSON/JsonHelper.cs b/template/cordovalib/JSON/JsonHelper.cs
index 63956c0..77c7233 100644
--- a/template/cordovalib/JSON/JsonHelper.cs
+++ b/template/cordovalib/JSON/JsonHelper.cs
@@ -12,7 +12,11 @@
limitations under the License.
*/
-using Newtonsoft.Json;
+using System;
+using System.Runtime.Serialization.Json;
+using System.IO;
+using System.Text;
+using System.Diagnostics;
namespace WPCordovaClassLib.Cordova.JSON
{
@@ -28,7 +32,29 @@ namespace WPCordovaClassLib.Cordova.JSON
/// <returns>JSON representation of the object. Returns 'null' string for null passed as argument</returns>
public static string Serialize(object obj)
{
- return JsonConvert.SerializeObject(obj);
+ if (obj == null)
+ {
+ return "null";
+ }
+
+ DataContractJsonSerializer ser = new DataContractJsonSerializer(obj.GetType());
+
+ MemoryStream ms = new MemoryStream();
+ ser.WriteObject(ms, obj);
+
+ ms.Position = 0;
+
+ string json = String.Empty;
+
+ using (StreamReader sr = new StreamReader(ms))
+ {
+ json = sr.ReadToEnd();
+ }
+
+ ms.Close();
+
+ return json;
+
}
/// <summary>
@@ -39,7 +65,23 @@ namespace WPCordovaClassLib.Cordova.JSON
/// <returns>Deserialized object instance</returns>
public static T Deserialize<T>(string json)
{
- return JsonConvert.DeserializeObject<T>(json);
+ DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(T));
+ object result = null;
+ try
+ {
+ using (MemoryStream mem = new MemoryStream(Encoding.UTF8.GetBytes(json)))
+ {
+ result = deserializer.ReadObject(mem);
+ }
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine(ex.Message);
+ Debug.WriteLine("Failed to deserialize " + typeof(T) + " with JSON value :: " + json);
+ }
+
+ return (T)result;
+
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[4/4] cordova-wp8 git commit: backing out version number to 3.9.0-dev
Posted by pu...@apache.org.
backing out version number to 3.9.0-dev
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/3ef90c08
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/3ef90c08
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/3ef90c08
Branch: refs/heads/master
Commit: 3ef90c084bac324add730b3382859dc5a4e783cd
Parents: 3334a3c
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu May 14 17:33:08 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu May 14 17:33:08 2015 -0700
----------------------------------------------------------------------
VERSION | 2 +-
package.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/3ef90c08/VERSION
----------------------------------------------------------------------
diff --git a/VERSION b/VERSION
index fcdb2e1..724ee60 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.0.0
+3.9.0-dev
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/3ef90c08/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index abd170d..31932f1 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "cordova-wp8",
- "version": "4.0.0-dev",
+ "version": "3.9.0-dev",
"description": "cordova-wp8 release",
"main": "bin/create",
"repository": {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[3/4] cordova-wp8 git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/cordova-wp8
Posted by pu...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/cordova-wp8
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/3334a3c0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/3334a3c0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/3334a3c0
Branch: refs/heads/master
Commit: 3334a3c0bd98343ed1024fb414d74ee43f51a57e
Parents: fbbf1af 14b6cc3
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu May 14 17:30:28 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu May 14 17:30:28 2015 -0700
----------------------------------------------------------------------
VERSION | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[2/4] cordova-wp8 git commit: allow use of json.net serialization via
an extra optional arg. Close #78
Posted by pu...@apache.org.
allow use of json.net serialization via an extra optional arg. Close #78
Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/fbbf1aff
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/fbbf1aff
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/fbbf1aff
Branch: refs/heads/master
Commit: fbbf1aff888c54a2757060609d4c02a4e0f0ed89
Parents: c4498b3
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Thu May 14 15:39:48 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Thu May 14 17:28:45 2015 -0700
----------------------------------------------------------------------
template/cordovalib/JSON/JsonHelper.cs | 68 ++++++++++++++++++-----------
1 file changed, 42 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/fbbf1aff/template/cordovalib/JSON/JsonHelper.cs
----------------------------------------------------------------------
diff --git a/template/cordovalib/JSON/JsonHelper.cs b/template/cordovalib/JSON/JsonHelper.cs
index 77c7233..1e8953c 100644
--- a/template/cordovalib/JSON/JsonHelper.cs
+++ b/template/cordovalib/JSON/JsonHelper.cs
@@ -17,6 +17,7 @@ using System.Runtime.Serialization.Json;
using System.IO;
using System.Text;
using System.Diagnostics;
+using Newtonsoft.Json;
namespace WPCordovaClassLib.Cordova.JSON
{
@@ -30,30 +31,37 @@ namespace WPCordovaClassLib.Cordova.JSON
/// </summary>
/// <param name="obj">object to serialize</param>
/// <returns>JSON representation of the object. Returns 'null' string for null passed as argument</returns>
- public static string Serialize(object obj)
+ public static string Serialize(object obj, bool bUseJsonDotNet = false)
{
- if (obj == null)
+ if (bUseJsonDotNet)
+ {
+ return JsonConvert.SerializeObject(obj);
+ }
+ else if (obj == null)
{
return "null";
}
+ else
+ {
- DataContractJsonSerializer ser = new DataContractJsonSerializer(obj.GetType());
+ DataContractJsonSerializer ser = new DataContractJsonSerializer(obj.GetType());
- MemoryStream ms = new MemoryStream();
- ser.WriteObject(ms, obj);
+ MemoryStream ms = new MemoryStream();
+ ser.WriteObject(ms, obj);
- ms.Position = 0;
+ ms.Position = 0;
- string json = String.Empty;
+ string json = String.Empty;
- using (StreamReader sr = new StreamReader(ms))
- {
- json = sr.ReadToEnd();
- }
+ using (StreamReader sr = new StreamReader(ms))
+ {
+ json = sr.ReadToEnd();
+ }
- ms.Close();
+ ms.Close();
- return json;
+ return json;
+ }
}
@@ -63,24 +71,32 @@ namespace WPCordovaClassLib.Cordova.JSON
/// <typeparam name="T">type of the object</typeparam>
/// <param name="json">json string representation of the object</param>
/// <returns>Deserialized object instance</returns>
- public static T Deserialize<T>(string json)
+ public static T Deserialize<T>(string json, bool bUseJsonDotNet = false)
{
- DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(T));
- object result = null;
- try
+
+ if (bUseJsonDotNet)
{
- using (MemoryStream mem = new MemoryStream(Encoding.UTF8.GetBytes(json)))
- {
- result = deserializer.ReadObject(mem);
- }
+ return JsonConvert.DeserializeObject<T>(json);
}
- catch (Exception ex)
+ else
{
- Debug.WriteLine(ex.Message);
- Debug.WriteLine("Failed to deserialize " + typeof(T) + " with JSON value :: " + json);
- }
+ DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(T));
+ object result = null;
+ try
+ {
+ using (MemoryStream mem = new MemoryStream(Encoding.UTF8.GetBytes(json)))
+ {
+ result = deserializer.ReadObject(mem);
+ }
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine(ex.Message);
+ Debug.WriteLine("Failed to deserialize " + typeof(T) + " with JSON value :: " + json);
+ }
- return (T)result;
+ return (T)result;
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org