I’m adding this here as a reminder to myself. If you want to convert a dictionary in simple JSON format to a dictionary in .NET 4.0, you can’t use the DataContractJsonSerializerSettings that is available in .NET 4.5, so if you don’t want to use a 3rd party source (like JSON.NET), you need to be able to serialize/deserialize it yourself. Fortunately, this is fairly simple for a dictionary as follows:

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace x
{
    [Serializable]
    public class JSONDictionary<T> : Dictionary<string, T>, ISerializable
    {
        protected JSONDictionary(SerializationInfo info, 
                                 StreamingContext context)
        {
            foreach (SerializationEntry value in info)
                Add(value.Name, (T)info.GetValue(value.Name, typeof(T)));
        }

        public override void GetObjectData(SerializationInfo info, 
                                           StreamingContext context)
        {
            foreach (KeyValuePair<string, T> value in this)
                info.AddValue(value.Key, value.Value);
        }
    }
}

Then just use this in place of the dictionary in your serializable object.

[DataContract()]
public class Response
{
    [DataMember(Name = "my_dictionary", IsRequired = true)]
    public JSONDictionary<double> MyDictionary { get; set; }
}

And you’re all set. (Note that I haven’t dealt with dictionary keys of types other than string.)

Advertisements

I haven’t posted much lately, but here’s the result of this past season in baseball.

20150919_AMUL

It was a fun season with two of my brothers, Doug and Matt on the team. We lost the first game of the season to the Kooy Brothers team and forfeited the fifth game due to a shortage of players, but won the rest of the games. The final game of the playoffs was a close come from behind walk-off win against the Kooy Brothers.

 


 

Smalls: I was gonna put the ball back.
Squints: But it was signed by Babe Ruth!
Smalls: Yeah, you keep telling me that! Who is she?
Ham Porter: WHAT? WHAT?

“Not all truthful statements must be free from restriction…” – Supreme Court of Canada

Let’s hope that “speaking the truth in love” remains to be free…

http://www.ottawacitizen.com/news/Freedom+expression+absolute/8101020/story.html

“The fallacy lies in thinking that appeals to authority constitute reasons for interpreting texts a certain way; but in fact, unless that authority’s reasons are given, the only thing that such appeals establish is that the writer is under the influence of the relevant authority!”

D.A. Carson – “Exegetical Fallacies”

I’ll add another post. 🙂

Perhaps in June or July…

We do not believe God has accommodated himself and his word to (as evangelical feminists see it) sinful patriarchalism, so that the “truth” of God’s word must be separated from the “sin” of patriarchy. According to this view, the biblical message is no longer sufficient but has been corrupted by a fallen aspect of the ancient biblical language and culture…

Because the Bible is God’s own chosen self-revelation, we must take seriously the language God chose to use to communicate to us what he is like. This revelation, by God’s choice, includes all the masculine God-language of the Bible, and therefore it cannot be dismissed as merely the by-product of a patriarchal cultural. To dismiss the masculine language for God in the Bible is to dismiss how God has spoken of himself, and this is a serious matter…

More… (source)

Well, it’s been four months since I’ve had time to write anything much. I have a little bit of time today, since I have the day off, but I’ll still be busy. I wish that I had some more time to write, but most of the time that I would have had available is now being taken up with writing minutes and such, since I took on the task of being the clerk to council at our church. It’s not too difficult of a position, but it does take away from some of your time – especially if you are the type of person who is picky on details as I tend to be, and not so much a natural writer.

On other fronts, my daughter Niamh is in Jr. Kindergarten now. She goes twice a week and is enjoying it. William is in Grade 1 now, and he seems to like it as well. He doesn’t seem to mind going every day of the week, and he seems to be flourishing this year. We bought him a bunch of “Bob Books” and he really enjoys reading them, so his reading skills are rapidly improving. He also pays much better attention when we do devotions at supper time and can usually repeat most of the details of the Bible stories that we read.

Alana just had her birthday yesterday, so I bought her “Corner Gas: Season 004”, and went out to get her ice cream from the Marble Slab Creamery. On Sunday we will celebrate her birthday with my parents, brothers and sisters in law after church.

Anyway, I should probably get to writing the minutes of last Tuesday’s meeting, as well as notes on the home visit on Monday…