|
|
Comments and Discussions
|
|
 |

|
No problem, thanks! It's a nice help for me instead of checking around for nulls
|
|
|
|

|
how does the output size compare?
to json.net , servicestack.text...
also what about memory usage while serializing,deserializing?
also is there features that json.net or servicestack.text that fastJson doesn't have?
thanks
|
|
|
|

|
Json is a pretty well defined standard so the sizes should be the same however you might get marginally small output sizes from fastJSON with its $types extension.
fastJSON caches type information for speed but the serialized/deserialize uses no memory (reclaimed by the clr after use).
I can't really say anything about the feature set of other serializers.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
thanks
i just checked it,
and the json.net output is smaller than fastJson:
json.net:
[{"Id":123,"Phone":"03-546-4562","Name":"asdas asd asd"},{"Id":321,"Phone":"08-566-5836","Name":"ewrqwer qwer ewrw"}]
fastJson:
[{"$types":{"ClientTester.Testing+MyClass, ClientTester, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null":"1"},"$type":"1","Id":123,"Phone":"03-546-4562","Name":"asdas asd asd"},{"$type":"1","Id":321,"Phone":"08-566-5836","Name":"ewrqwer qwer ewrw"}]
why does it do that, why does it need type information? how can i make it output in the same format of json.net but keep it with fast performance?
thanks
|
|
|
|

|
You can get the same results if you disable fastJSON's extensions.
The type information is for deserializing the exact object model and support for polymorphism.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
also i tried this:
var p = JSON.Instance.Parameters;
p.UseExtensions = false;
p.UsingGlobalTypes = false;
p.ShowReadOnlyProperties = true;
now my class
public class MyClass
{
public int Id { get; set; }
public string Phone { get; set; }
public string Name { get; set; }
}
private readonly MyClass[] cArr = new[] { new MyClass { Id = 123, Name = "asdas asd asd", Phone = "03-546-4562" }, new MyClass { Id = 321, Name = "ewrqwer qwer ewrw", Phone = "08-566-5836" } };
now it does turns into the same json
but i throws exception on deserialization
because the type.IsGenericType is false when you called
GetGenericDefinition on ToObject
invalid operatioexception
at System.RuntimeType.GetGenericTypeDefinition()
at fastJSON.JSON.ToObject(String json, Type type) in D:\UTX\ClientTester\JSON\JSON.cs:line 161
changed it to this
if (o is List<object>)
{
if (type != null && type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary<,>)) // kv format
return RootDictionary(o, type);
if (type != null && type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>)) // deserialize to generic list
return RootList(o, type);
else
return (o as List<object>).ToArray();
}
and the
var o = JSON.Instance.ToObject<object[]>(sj2);
i changed to
var o = JSON.Instance.ToObject<MyClass[]>(sj2);
but now instead of returning me the object[] as MyClass[]
it returns me object[Dictionary<string,object>]
or something like that
why doesn't it just works?
checked the performance compared to json.net
serialization x2 fast
deserialization x6 fast
how can i make it work?
thanks
|
|
|
|

|
Try ToObject<List<MyClass>>(...)
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
this works,
but i want it to work with arrays too,
like json.net just with better performance
ToObject(...)
i like arrays more, because they are more lightweight and faster then list(as list contains and manipulates array inside)
and i have a constant size array of object that their properties only changed not the number of items
also maybe this should be the default, as usually people expect the standart short json without type info, laterif they want they can change it
var p = JSON.Instance.Parameters;
p.UseExtensions = false;
p.UsingGlobalTypes = false;
p.ShowReadOnlyProperties = true;
is there a way to support polymorphism without writing the type info and still be fast?
also try to see why on some cases servicestack.text
is faster, maybe it doesn't support polymorphism
like fastJson
so tell me how it goes, as i really liked the performace and all the use of DynamicMethod and ILGenerator in it as oppoesed to reflection on all the others(except maybe servicestack.text which does that too)
great code, very light and readable,
as opposed to other libraries which are really bloated and too big for what they do
thanks
|
|
|
|

|
Hi Mehdi,
I made a simple application just to test my class conversion. Serialization works great, unfortunatelly I cannot deserialize that very same json text to my object, I get the above error message.
I'm not an expert C# developer, so it might be easily that I did something wrong, can please point me to the right direction?
This would be my code. First I put JSON text create from OrderIn class into a textbox, then trying to deserialize that text back into OrderIn.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace fastJSON_experiment
{
public partial class Form1 : Form
{
public class OrderItemIn
{
public OrderItemIn(string itemnumber, string quantity)
{
ItemNumber = itemnumber;
Quantity = quantity;
}
public string ItemNumber { get; set; }
public string Quantity { get; set; }
}
public class OrderIn
{
public OrderIn()
{
Items = new List<OrderItemIn>();
}
public string Token { get; set; }
public string SAPSys { get; set; }
public string RequestID { get; set; }
public string MethodName { get; set; }
public List<OrderItemIn> Items { get; set; }
}
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OrderIn o = new OrderIn();
o = (OrderIn)fastJSON.JSON.Instance.ToObject(textBoxJSON.Text);
textBoxProperty.Text = o.MethodName;
}
private void button3_Click(object sender, EventArgs e)
{
textBoxJSON.Text = "";
OrderIn oi = new OrderIn();
oi.Token = "lunch33aught96parchduechis93gook61mist85cove";
oi.RequestID = "k32jk3kj2k23kh4";
oi.MethodName = "Simulationtest";
oi.SAPSys = "T15/105";
oi.Items.Add(new OrderItemIn("123456", "1"));
oi.Items.Add(new OrderItemIn("124456", "11"));
oi.Items.Add(new OrderItemIn("233456", "13"));
oi.Items.Add(new OrderItemIn("123456", "14"));
oi.Items.Add(new OrderItemIn("123456", "81"));
fastJSON.JSON.Instance.Parameters.UseExtensions = false;
textBoxJSON.Text = fastJSON.JSON.Instance.ToJSON(oi);
}
}
}
Thank you,
Tibor
|
|
|
|

|
Use fastJSON.JSON.Instance.Parameters.UseExtensions = true; or do ToObject<OrderIn>()
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
I've tried with UseExtensions true, but got the same error, not to mentioned that I'd like to use it without extentsion.
Then I've tried with ToObject() and now I got this error:
{"Failed to fast create instance for type 'fastJSON_experiment.Form1+OrderItemIn' from assemebly 'fastJSON_experiment.Form1+OrderItemIn, fastJSON experiment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'"}
Oh, by the way, I'm using .NET Framework 4.0.
|
|
|
|

|
OrderItemIn must have a default constructor i.e public OrderItemIn() { }
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
That was it! Thank you very much.
|
|
|
|

|
Mehdi, have you tried using FormatterServices.GetUninitializedObject? It could be a viable alternative to default constructors, albeit with the obligatory warning of "none of your default field initializers will run" - which is probably just fine for POCOs anyway.
|
|
|
|

|
Interesting... I will have to check it's performance.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Hi Mehdi,
I write simple tests:
public void SimpleTests()
{
#region ulong
var s = JSON.Instance.ToJSON(ulong.MaxValue);
var o = JSON.Instance.ToObject(s);
Assert.That(ulong.MaxValue, Is.EqualTo(o));
#endregion
#region float
s = JSON.Instance.ToJSON(float.MinValue);
o = JSON.Instance.ToObject(s);
Assert.That(float.MinValue, Is.EqualTo(o));
s = JSON.Instance.ToJSON(float.MaxValue);
o = JSON.Instance.ToObject(s);
Assert.That(float.MaxValue, Is.EqualTo(o));
#endregion
#region double
s = JSON.Instance.ToJSON(double.MinValue);
o = JSON.Instance.ToObject(s);
Assert.That(double.MinValue, Is.EqualTo(o));
s = JSON.Instance.ToJSON(double.MaxValue);
o = JSON.Instance.ToObject(s);
Assert.That(double.MaxValue, Is.EqualTo(o));
#endregion
#region decimal
s = JSON.Instance.ToJSON(decimal.MinValue);
o = JSON.Instance.ToObject(s);
Assert.That(decimal.MinValue, Is.EqualTo(o));
s = JSON.Instance.ToJSON(decimal.MaxValue);
o = JSON.Instance.ToObject(s);
Assert.That(decimal.MaxValue, Is.EqualTo(o));
#endregion
}
And all of them throw exceptions.
thanks for your feedback,
Gintas
|
|
|
|

|
Most of test encounter rounding errors, and you should also use ToObject<type>() when you are checking the types since JSON has no notion of types.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
it does not help :
s = JSON.Instance.ToJSON(decimal.MinValue);
o = JSON.Instance.ToObject(s);
Assert.That(decimal.MinValue, Is.EqualTo(o));
//-79228162514264337593543950335 != 1
s = JSON.Instance.ToJSON(decimal.MaxValue);
o = JSON.Instance.ToObject(s);
Assert.That(decimal.MaxValue, Is.EqualTo(o));
// 79228162514264337593543950335 != -1
|
|
|
|

|
Hi Mehdi,
I run following test:
[Test]
public static void ObjectWithNullPropertyTest()
{
var ds = new MultiValue();
ds.keys = new List<object>(){1,2,3,4,5};
ds.values = new List<string>(){"1", "2", "3", "4", "5"};
ds.keySel = 3;
ds.refId = new Guid();
fastJSON.JSONParameters param = new JSONParameters();
param.SerializeNullValues = false;
param.UseExtensions = false;
param.UseFastGuid = false;
var newJson = fastJSON.JSON.Instance.ToJSON(ds, param);
Assert.AreEqual(newJson, "{\"values\":[\"1\",\"2\",\"3\",\"4\",\"5\"],\"keys\":[1,2,3,4,5],\"keySel\":3,\"refId\":\"00000000-0000-0000-0000-000000000000\"}");
}
with the following objects:
public class SingleValue
{
public SingleValue()
{
}
public SingleValue(string value, Guid refId)
{
this.value = value;
this.refId = refId;
}
public string value { get; set; }
public Guid refId { get; set; }
}
public class MultiValue : SingleValue
{
public MultiValue()
{}
public MultiValue(List<string> values, List<object> keys, object keySel, Guid refId)
{
this.values = values;
this.keys = keys;
this.keySel = keySel;
this.refId = refId;
}
public List<string> values { get; set; }
public List<object> keys { get; set; }
public object keySel { get; set; }
}
The problem is, that there's a comma to much after the '"keySel":3, ,' I was able to solve the problem by commenting out the following two lines in the JsonSerializer.cs
...
else
{
WritePair(p.Name, o);
if (o != null && _params.UseExtensions)
...
My question is now: why is the 'if' statement in there? I couldn't follow the logic of it or the comment (last non null).
Thanks for your help,
Chris
|
|
|
|

|
I will have to check it was probably for an edge case regarding the comma outputs.
Thanks Chris!
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Hi Mehdi,
were you able to look at the problem yet?
thanks,
Chris
|
|
|
|

|
Not yet but it is on my todo list, I have to create some unit test for the comma edge cases.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
This should be fixed in v2.0.12
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Hi Mehdi,
I try to write simple test and it fails.
Here's my test code:
sbyte zero = 0;
s = JSON.Instance.ToJSON(zero);
o = JSON.Instance.ToObject(s);
Assert.That(zero, Is.EqualTo(o));
parser throws exeption:
System.IndexOutOfRangeException was unhandled by user code
HResult=-2146233080
Message=Index was outside the bounds of the array.
Source=fastJSON
StackTrace:
at fastJSON.JsonParser.ParseNumber() in d:\tmp\fastJSON\fastJSON\JsonParser.cs:line 293
at fastJSON.JsonParser.ParseValue() in d:\tmp\fastJSON\fastJSON\JsonParser.cs:line 122
at fastJSON.JsonParser.Decode() in d:\tmp\fastJSON\fastJSON\JsonParser.cs:line 46
at fastJSON.JSON.ToObject(String json, Type type) in d:\tmp\fastJSON\fastJSON\JSON.cs:line 143
at fastJSON.JSON.ToObject(String json) in d:\tmp\fastJSON\fastJSON\JSON.cs:line 128
at fastJSON.Tests.Tests.Testsbyte() in d:\tmp\fastJSON\fastJSON.Tests\Tests.cs:line 144
InnerException:
thanks for your feedback,
Gintas
|
|
|
|

|
An edge case but you can fix it with :
...
if (index == json.Length)
break;
...
In jsonparser.cs ParseNumber() line 293.
Thanks.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
hi Mehdi,
i'm converting values with special characters (i.e. German Umlaut, etc.) from Objects to Json. The problem is now, that those values are converted to utf-8 escaped character (i.e. ü ==> \\u00FC).
I was wondering, why those characters are escaped and if there's a way around it, without converting it after the serialization.
thanks for your help,
Chris
|
|
|
|

|
The JSON standard states that all non-ASCII characters should be escaped like that.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
For some weird reason even what you say is true
i have the following situation...
var jsonText = "{\"some_number\": 108.541,\"date_time\": \"2011-04-13T15:34:09Z\", \"serial_number\": \"ασδασδα\",\"more_data\": {\"field1\": 1.0, \"field2\": \"hello\"}}";
var dict = (Dictionary<string,object>)fastJSON.JSON.Instance.Parse(json);
textbox1.Text = fastJSON.JSON.Instance.ToJSON(dict);
The textbox displays \u chars for the greek chars i put in serial_number.
The problem is that if i send that json object to a php Rest API the stored mysql string does not display greek but rather japanese at best. I happened to get json from that same rest api and my client displayed weird characters also (NOT ALWAYS though ??? i cannot seem to replicate, sometimes i see greek characters even though phpmyadmin displays Glyphs and sometimes i see Glyphs).
While using either System.Web.Script.Serialization.JavaScriptSerializer or Newtonsoft.Json
both the textbox and phpmyadmin display the greek characters properly.
I really hope you can fix this.
|
|
|
|

|
fastJSON does not have any problem deserializing the string you provided (with non ascii characters) and you should use ToObject() instead of Parse() if you want the object structure, Parse should be used when you don't know the structure or the container object beforehand.
Serialize is a different matter, currently fastJSON outputs in ascii format and all non ascii characters are escaped as \uxxxx (>32 and <128), the php side probably does not implement parsing \uxxxx chars.
Having said the above, I have contacted Master Crockford for clarification regarding UTF8/Unicode string defaults, I will post back when I get an answer.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
I am currently at work and i don't have access to my code.
I tested fastJSON Serialize and it produces the same result as what the server hands me over (that was previously serialized with Json.NET).
I am really at a loss.
Either the Streamwriter.Write(json) does something internally that i am not aware of and the php backend manages to parse it and send it to mysql as normal or i have no idea whatsoever what may be the case. Since the server sends me the same json result in fastJSON or json.net or system.web.
Since it happened at some point and the result was displayed not as intended using fastJSON i really cannot continue using it until the problem is resolved. You do realize that "some point" in computer science cannot be taken lightly (i.e. it was just one time and the likes...)
I am using fastJSON in most cases due to speed and mostly because of the code being that small.
|
|
|
|

|
I have created a JSONParameters.UseEscapedUnicode which will control the unicode output so this should work for you.
I will post this soon (testing at the moment )
Thanks.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Make sure you are using Encoding on your streams : http://msdn.microsoft.com/en-us/library/3aadshsx.aspx[^]
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Ok i seems to be working just fine in those 2 situations...
Either by using...
StreamWriter sw = new StreamWriter(request.GetRequestStream(),Encoding.ASCII);
sw.Write(json);
sw.Close();
with the default output.
or...
private static Regex DECODING_REGEX = new Regex(@"\\u(?<Value>[a-fA-F0-9]{4})", RegexOptions.Compiled);
private const string PLACEHOLDER = @"#!#";
public static string DecodeEscaped( string value )
{
return DECODING_REGEX.Replace(
value.Replace(@"\\", PLACEHOLDER),
m => {
return ((char)int.Parse(m.Groups["Value"].Value, NumberStyles.HexNumber)).ToString(); })
.Replace(PLACEHOLDER, @"\\");
}
public static string httpPost(string api,string json)
{
json = DecodeEscaped(json);
HttpWebRequest request =
(HttpWebRequest)WebRequest.Create(host+api);
request.Method = "POST";
request.ContentType = "application/json";
StreamWriter sw = new StreamWriter(request.GetRequestStream());
sw.Write(json);
sw.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream());
string responseJson = sr.ReadToEnd();
sr.Close();
return responseJson;
}
relying on the default/autodetect encoding from the Streamwriter.
I will definitely stick with the first one that seems less error prone
I wasn't using Encoding at first.
modified 3 Dec '12 - 12:37.
|
|
|
|

|
I have fixed this issue in v2.0.11.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|
|

|
Thanks!
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|
|

|
When checking for the presence of attributes, you'll want to use IsDefined, rather than GetCustomAttributes.
MSDN[^]
It is about 4x times faster than using GetCustomAttributes.
|
|
|
|

|
Thanks Andrew!
Although fastJSON only does this once per type but still anything that goes faster is good
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
See below as well... a few more suggestions.
|
|
|
|

|
Take the following with a grain of salt, I'm looking over the code fairly quickly, so I might miss obvious things.
-SafeDictionary - Why have an internal class contain locks, especially on an instance level? I'd imagine that serializing/deserializing a string should not run into multi-threaded issues. Furthermore, you're breaking a standard expectation for .NET (static members are thread safe, while instance members are not). I think it would be safe enough to just use regular Dictionaries and rely on the user of your class to handle the locking properly. Otherwise, performance suffers for those not using in a multi-threaded way.
-Formatter.AppendIndent - Since you're just appending four spaces, you might want to use StringBuilder.Append(char, int) and just multiply count by 4. It'd likely be faster.
-JSON.ToObject - You have several calls to GetGenericTypeDefinition. You may want to cache that result off rather than calling it again and again.
-JSON.CreateMyProp - You may want to look at this[^]. You could do an initial test to see if the type is Nullable, get the underlying type and then reduce the number of checks that you have (ex. type.GetGenericArguments()[0]).
-myPropInfo - You spend time trying to find out what type something is. Why not instead of capturing that into a bool, capture a delegate to do something with it? It would reduce the amount of code you have and allow you to not pay the penalty of going over all the different types again. You could also use a factory pattern to create a concrete type (from an abstract base that defines the functionality) that handles it for the specific case. Either way would work.
|
|
|
|

|
I guess: SafeDictionary has locks because it is used by the JsonRegistry which is static. Therefore, multiple threads can access the dictionary at runtime. Since the dictionary is created and populated on demand (new type to parse etc), it should be thread-safe.
I have tried to replace SafeDictionary with the ConcurrentDictionary but this decreases portability a lot. In fact I believe that the JsonRegistry should not be static. Changing parameters can too easily lead to unexpected output:
1. Set IncludeReadOnly= false, serialize
2. Set IncludeReadOnly= true, serialize=> fails, since it uses the cache which was populated based on the previous definition (1).
Aron
|
|
|
|

|
Hi Andrew,
in my private version of FastJson I tried to implement your proposal in replacing the myPropInfo with a dictionary lookup. The outcome was devastating. The performance dropped about more than 200% in the given benchmark.
Interesting however is, that a combination if-else block (as-is) with a dictionary brings a significant bonus when exotic types are used.
You can check that version at: http://www.innotags.de/download/Apolyton.FastJSON.zip[^]
|
|
|
|

|
Interesting.
I wasn't recommending a dictionary for that portion, but rather to capture an action to perform instead of a set of multiple flags to determine what to do later.
|
|
|
|

|
If any one can make fastJSON faster I am all ears
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Hi Mehdi,
nice work! I run though into a problem, when I tried to deserialize a JSON into a polymporphic objects. My object model is similar to city => list<zoo> => list<animals>
Since I don't know what animals are within a zoo, I just have a type animal for each zoo. The problem is now, that only animals of type animal are created and not dogs, cats, etc.
Now, I would like to solve this problem through a custom type animal, in which I can check the supplied json for the necessary properties for each animal (dog barks, cat miaus, etc.)
The issue is now, that the current implementation (2.0.9) passes only a string to the custom deserializer and throws an error, if the custom type consist of multiple properties or additional object. I was now wondering if this could be changed to the passed parameter from string to a dictionary or full json object.
thanks for your feedback,
Chris
|
|
|
|

|
Thanks Chris!
"Custom Types" is intended for RECT, COLOR, ... etc. not for classes. fastJSON will automatically handle nested types for you if you have enabled the extensions (and given the dog inherits from animal).
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
hi Mehdi,
thanks for the quick response. The Problem is that those nested types defined as follow in JSON:
A point:
{ "geometry" :
{ "x" : 2781859.5718259001,
"y" : 5104563.3898882624
}
A polygon:
{ "geometry":
{ "rings":
[
[
[123.445, 23.456],
[33.123, 23.4345,
[33.125, 23.4345,
[123.2342, 23.4345]
],
[
[123.445, 23.456],
[33.123, 23.4345,
[33.125, 23.4345,
[123.2342, 23.4345]
]
]
}
}
(PS: I know, this is not best way to do this, but it was given to me as such and can not be changed )
I would need now to create a GeometryPoint and GeometryPolygon object, which belongs to a dataset which has a property Geometry (which can be point or polygon).
==> Dataset.Geometry could be of type GeometryPoint or GeometryPolygon (and both inherite from the base type Geometry)
I believe, that for this purpose I would need a custom type with needs to be able to parse the appropriate JSON substrings, yet those substrings need to be passes as Dictionary. Therefore my question regarding the passed type.
Unless, there's another approache to this problem?
thanks for your help,
Chris
|
|
|
|

|
Ah! the data does not have the $type extensions...
Try the Parse() method instead, it will give you a dictionary and list of object collections.
Its the man, not the machine - Chuck Yeager
If at first you don't succeed... get a better publicist
If the final destination is death, then we should enjoy every second of the journey.
|
|
|
|

|
Hi Mehdi,
We are planning to use your work in our company. In that scope, I have done some major code review. For now, I can offer you two different packages, if you are interested: a small one and a big one.
The first is primarily focusing on the public API applies primarily minor code review changes. This should definitely a value to the community. Performance characterisics should not have been changed.
The second package is an intense review, in brief details:
- Harmonizing with .NET naming conventions
- Applying good principles like separation of concerns (with perf. in mind).
- Improving exception reporting
- Increasing flexibility of the framework: Property opt-in, Property opt-out. This should increase performance in real-life use cases.
- Small performance drop 1-3% (custo types always available)
- Unit test driven: all native serilization/ deserialization is tested (46+ Tests)
- 5+ Bug fixes
- Improved debugging capabilities
In the near future, I will have to make the basic funcionality again available under Silverlight 5. Which critical feature was removed by Microsoft?
Best Regards,
Aron
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
Smallest, fastest polymorphic JSON serializer (with Silverlight4 and MonoDroid support)
| Type | Article |
| Licence | CPOL |
| First Posted | 19 Feb 2011 |
| Views | 1,555,537 |
| Downloads | 25,755 |
| Bookmarked | 462 times |
|
|