Adventures in JSON parsing with C#

Despite building applications with C# for years, I was frustrated today with some basic JSON parsing. This is something that I have done hundreds of times in Ruby and Python, where parsing JSON consists of deserializing into a Hash (Ruby) or Dictionary (Python) on the fly without defining a class, or mapping, beforehand. It’s easy to build the objects on the fly in the dynamic languages. But, with C# being a statically typed language, it’s taken a long time to get to that point. This becomes important as you consume many JSON endpoints from a service, it saves us time if we don’t have to model all of these responses in C# before making requests. This proved to be an opportunity to catch up with the state of art in C# for dynamically parsing JSON.


Consume a JSON string (such as the following) in a C# program, hopefully creating some sort of dynamic object on the fly that we can work with like any other C# object, and then doing something with the object: saving it in database, sending it elsewhere or rendering to a screen.


Step 1 – Parse JSON, dynamically converting it into a C# object

Again, trying to get up to speed and taking the most “modern” approach by dynamically parsing without pre-defining classes or mappings. Looking at some samples, I see mention of a JsonArray type, and a JsonObject in conjunction with the newer .NET Http Client library. But, I cannot seem to use these, and am not sure if they still exist. So, I’m going to quickly switch gears and use Json.NET, since it’s essentially been the de-facto JSON parsing library for .NET applications for years, and that doesn’t seem to be any different now.

I’ve said “dynamic” many times already, and as luck would have it, .NET 4 introduced dynamic types. dynamic types bypass compile time checking. Great, that seems promising. Rick Strahl has a post where he introduces us to Json.NET’s dynamic support, using JObject and JArray

Step 2 – Do something with the C# object

So, great, we have a nice dynamic c# object, but did you notice something in that sample? The last record’s supervisor has disparate value types. This is perfectly valid JSON, per the JSON spec:

A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.

Nowhere does it say that the value type has to be same for the property across all instances in an array, which if they were all the same type, we’d be done already. So, how do handle this case with our Json.NET JObject instance. As a demonstration, let’s say the requirement is to just take the first one if it’s an array.


Here’s a little program to demonstrate

Overall, the Json.NET looks like the solution we were looking for, with a concise few lines of code to parse and process the result. It took entirely too long to get to this point though, both in terms of the language and in my work to understand it today. Hopefully we’ll see more acceptance of dynamic parsing in C# and start moving more examples and codebases in that direction.

The Procrastinator’s guide to PIE

NOTE: when I started writing this, I thought the deadline was August 1st, turns it was extended today to August 8th. So, come back and read this next week I guess.

Enjoying your summer? Soaking in that Friday night feeling? Have that nagging thought in the back of your mind that you haven’t finished your PIE application for you great idea? Ah ha, I knew it. Since I’m one of the biggest procrastinators around, I feel your pain. But, wait, you say “I still have 3 10 more nights, there’s plenty of time to watch a couple shows on Hulu, get lost for a few hours reading blog posts, figuring what the heck PIE is, and maybe do a little coding, and then finish the application.” I know your tricks, that’s why I’m here to help.

All kidding aside, and even though I just moved to Colorado, I am here to help. I’ve enlisted to be a mentor in the upcoming session of PIE, joining forces with a who’s who of Portland and beyond talented technology, startup and marketing communities. Even if you don’t need my help, or if my help is no help at all, then you’ll still want to be a part of it to tap into the roster they’ve got lined up. Heck, I’m hoping I can learn a thing or two or a hundred in drafting off this group.

Let’s get to it, turn down your Spotify, Turntable, Mugasha or whatever the cool kids are listening to these days and focus.

What is PIE?

First, stuff you can read on their website, but I wanted to use the blockquote tag:

The Portland Incubator Experiment (PIE) is a partnership among leading brands, technology innovators, and Wieden+Kennedy-the largest privately held advertising and communications company in the world. It serves as a hub for community, entrepreneurship, and creative thinking.

So, it’s an incubator, it’s an experiment, it’s got help from Wieden+Kennedy and a bunch of their clients? Yes, yes, and yes. But, I know you, you’re looking to do more research, so here you go:

How do I apply?

Go to the website and fill out the application

When’s the application due?

August 1st August 8th (great, there goes my whole procrastinator’s angle)

What’s in it for me?

You’ll get $18,000, 3 months of office space, and access to a host of nice folks that may know a thing or two to help. Like:

What’s in it for PIE?

You’ll give PIE a 6% equity stake in your company. (source). You’ll probably need to devote yourself pretty fully to this endeavor too, time-wise, but if you’re worried about that, then, well, maybe you just keep on bootstrapping. That’s reality, hey, it’s my reality.

Of course, if your team knocks it out of the park, then PIE can keep this experiment going into the next class or further.

What if I don’t get in?

You certainly don’t need PIE’s permission to build the next big thing. Prove us all wrong and make us write a “The one that got away” post.

There’s probably a ton of applicants, why bother?
What’s the first rule of business? Show up.

You’ll never know until you try. Plus, according to Rick, the number of applicants “hasn’t been blowing the doors off.” so there goes that excuse.

When’s that application due again?

August 1st August 8th (@ 11:59 pm, I checked for ya)

Rocky Mountain Hi

I won’t dwell on the fact that it’s been 3 years since I last posted. As I work on posting regularly again, it will be fun to revisit the last few years.

But, the occasion of moving half-way across the country is enough to stir the blog into action again. This past weekend, I made the journey from Portland to Boulder, Colorado, marking the culmination of a frantic few months of tough decisions and planning. After 12 years in the Portland area, we decided it was time for a change. So, in a a quick 2-3 month time period we went from, “what if we moved?” to thinking about where we’d move to, on to packing up and hitting the road for Boulder.

The questions usually come up in the course of telling people this. Why Boulder? Why leave? The short version: sun, software, and adventure.

The longer version… Earlier this year, we adopted our son from Ethiopia, our third child and second boy. Now, I grew up in a 3 kid/2 boy household in Oregon, I’m perfectly aware of the ups and downs. But, we just couldn’t take it. The kids need to be able to go outside and move and the constant grey was no longer tolerable. Plus, we’d always lived in Oregon, save for a years of college in Washington, so the explorer aspect was definitely appealing. Finally, even as I see Portland’s tech startup scene with more spark in the last few weeks than there’s been in years, the energy of the Boulder software and startup community was unmistakably electric, so what better way to check it out than to live amongst it.

Portland still holds a special draw for us though, so one never knows where this road will lead. I’m still working for my same company in Portland, will be back in town on a somewhat regular basis, am still working with partners in Portland on my side-projects and we still own our house there. Didn’t exactly cut the cord, eh?

That will segue nicely into the next post I think…

Is it hot in here? Apps to help your macbook laptop stay cool

Working at Strands has presented the unique opportunity to work in an all Mac shop, which is fun seeing all the MacBook Pros and MacBook Airs around the office when I’m there. But, as many people quickly discover, these things get HOT, like burn your lap and destroy your child producing ability hot (not to mention the possible damage to the hardware itself). The question was posed at work with the ultra modern social media tool of “send email to whole company” about how to keep things cool. Based on the responses, seemed like information worth sharing.

Three apps were mentioned as ways to help boost the fans and monitor temperatures:

I installed smcFanControl and even after a day noticed pretty significant temperature reduction.

But, I was also reminded of a discussion on Stack Overflow a couple weeks back where Joel recommended an alternative approach to the heat problem, undervolting the CPU, with CoolBook.

So, there’s some options, and make sure you do some research first, wouldn’t want you doing any damage or voiding any warranties or anything.

WebVisions wrap-up

This last Thursday and Friday was the annual WebVisions conference here in Portland. 2008 marks my 4th year in attendance, and I definitely look foward to it every year. You can’t beat the price, it’s one of the cheapest conferences around and with it being local, there’s really not much excuse not to come and check out at least a few sessions and a keynote. Plus it’s a great chance to catch-up with my local developer and entrepreneur friends and meet some new ones.

My main point of feedback for the organizers if they read this. PLEASE PUT KEYNOTES IN THE MORNING!

All in all, WV was pretty good, though it didn’t feel as inspiring as the last couple of years. After last year, I made sure to avoid the workshops. As far as the sessions go, I was entertained and picked up some great info and good tips to follow-up on, but nothing that made me want to carve out a day or so to really think through. I can’t quite figure out why exactly, but one thing that I noticed that I didn’t read a single live-blog or blog post during the conference, it never even occurred to me. That’s a major shift from years past. Why didn’t it occur to me? Make a guess, Twitter. In years past, reading about the conference, during the conference has always kept that mind-buzz going.

Twitter is now the primary forum for conference back channel and instant recaps. Only problem was, Twitter was down for a good portion of the conference, so there was little in terms of immediate response loop. The conversation has migrated from the blogosphere to Twitter, but when Twitter is down, the conversation dies.

Here’s a quick round-up of the sessions I attended. Slide decks for at least some of these available on SlideShare. Other roundups can be found on the Silicon Florist.

RSS: Bleeding Edge Tips and Tricks
I only caught the last half, and I’ve seen Marshall talk about RSS before, but even then I still managed to pick up some new ideas, a testament to Marshall’s ability to keep finding new ways to digest more information, faster.

Drupal: This Aint Your Father’s CMS
I’ve just picked up Drupal in the last couple months for a project at Strands and this was my first opportunity to hear about it and ask questions after having actually spend considerable time working on it. I missed most of the actual presentation, but there was lots of time for q & a which was well worth it. Plus, we got to learn a little bit about OpenSourcery, which was new to me.

Going Fast on the Slow Mobile Web
Great update to Jason‘s talk in February at PDX Web Innovators. Cloud Four has been doing a lot of research on the performance capabilities of mobile phones, and a lot of that fresh new data was included here.

So You Want to Run a Startup
The startup story of SlideShare. This is my first time seeing Rashmi speak and I think it was a good session. Focus on metrics to measure success, understanding the size of your market, pros/cons of different business models, adapting plans to how the business/site/community take-off, and developing key advisors/investors. SlideShare is the poster child of web 2.0 in that it is a pure ad-based business model and its marketing strategy was to get on TechCrunch. They may just have been one of the few to succeed at that, as it they seem to growing nicely.

Star Wars Kid Is Your New Bicycle: The Changing Lives of Memes
Andy Baio’s talk attempting to identify how memes spread. This was definitely the most entertaining session, and I have to admit I hadn’t heard of a couple of the ones mentioned. But, I certainly remember Star Wars Kid and Numa Numa. Bottom line, I don’t think we can ever predict what’s going to truly go viral.

WebVisionary awards
I was excited to finally make it to an after party for WebVisions for the first time. This was a fun event and I managed to meet several tweeps for the first time. But, something that I’ve gotten used to with WebVisions, the online component of these awards is lacking (no nominees or winners listed as of now, but the lack of online presence is something that WV overall has struggled with to the point of giving up this year IMO, and this is a web conference). There was no transparency on nominees and with a couple multiple-award winners (Substance and Colour Lovers) I have to question the value of these awards. Not to take away from the winners, but with that, the apparent lack of nominees and the entry fee the awards just seemed kind of cheap. I suppose that’s why they rushed through them so fast. The ceremony itself was well done though.

Events to keep an eye on

The next couple weeks are going to be busy around these parts and just wanted to share some of the events I’m planning on attending.

Always one of my favorites and it’s cheap! Starts tomorrow.

Strands Portland Meet-up
Think Strands is all about Music and now Money? Think again. This meet-up will be a chance to preview the all new and meet more of the Strands team.

Portland Lunch 2.0 @ Vidoop
The Lunch 2.0 series continues at newly re-located to PDX Vidoop

Andy Baio talks side projects and acquisition at Portland Web Innovators
We’re thrilled to have Andy Baio, founder of leading the discussion. Should be awesome!

Breaking the silence

Hard to believe it’s been 6 months since my last post, but what can I say, I’ve been busy! Not only have I been silent on this here blog, but for those that I have talked with over the last few months can attest, I haven’t talked a whole lot about what I’m working on. Today is the day I get to tell my story. NetworthIQ has been acquired by Strands and I have joined the Strands team to work on moneyStrands, the upcoming personal finance solution. For info on how this news is going to impact NetworthIQ, be sure to read the post over there. This post contributes my personal perspective. Needless to say, I’m pretty excited about it.

It was just over 3 years ago that we started working on NetworthIQ. It was a bit of a bumpy ride. In the first couple months, I wasn’t sure if it was going to make it, but with a couple of high-profile press mentions we were off and running. The idea for NetworthIQ was pretty basic, apply the popular Web 2.0 principles of the time (social networking, public sharing, collective intelligence) and apply it to personal finance, something that hadn’t been done before. There was the occasional “this is the dumbest site ever” comment, but for the most part we always got great response and feedback from those that signed up, which was what kept me going.

Hard to believe that with the web being as global as is now, that the company that came calling was practically in your back yard. I spent two terms at OSU, and went through the disappointment of seeing my baseball career die, but now I’m back in Corvallis living out the dream. Pretty ironic. Not only that, as an active follower of the Silicon Florist and Silicon Forest, I already knew who Strands was and was following what they were doing.

So, how and why did NetworthIQ and Strands come together? Up until a few weeks ago, the face of Strands on the web was MyStrands, the social music site. It may seem odd for a personal finance site to come under that umbrella. But, now that moneyStrands has been announced, I think it starts to make a lot more sense right? Strands is starting to take the personalization and recommendation technology that they’ve built in new directions and personal finance was one of those directions. My primary job now is to channel my knowledge of the personal finance market gleaned from building NetworthIQ into the moneyStrands roadmap and keep NetworthIQ humming along.

Though it was a few months ago, it was sad to say good-bye to TransCore, I had many great opportunities to transition into software development (I started as a financial analyst) and got to work on some fun projects with great people there. But, when an opportunity to work on something that you are personally passionate about full-time and still allows you to support your family, it’s something worth making the jump for.

As for Corvallis, yes, I commute. Quite a bit different from my old commute (though I’m now even more disappointed in Oregon drivers). But, it’s only two days a week normally and the rest of time I’m up north here at home, or enjoying the quiet confines of the Sherwood public library (gotta love a city that provides free wi-fi. Even if its only downtown), or I’ve even been known to drop in on fellow web innovators and do a little co-working. I’ve also been able to make it to more events around PDX like PDX Web Innovators, Lunch 2.0, InnoTech, and BarCamp since it’s good to get out of the house a bit when working at home. However, after commuting 3 hours one day, I’m not exactly eager to make the drive into pdx proper that often, but it’s fun when I do.

Just wanted to add a personal thanks here to Todd, Jeff, and Aaron, my partners in crime at Fourio. Though we certainly had our struggles, the fact that we saw our first released product (a side-project no less) through to an exit is something to be proud of. I don’t want to make this into an academy speech, but I haven’t shared in a while, I should mention that my wife has been great through all of this, supporting my crazy/obsessive side-project turned startup dreams and for that I am extremely grateful. See honey, it wasn’t a waste of time :-).

Can I get a yay Windows? No?

The glowing apple is becoming ubiquitous. Is this indicative of the conference experience these days?

First a picture from RubyConf held earlier this month:

Reminded me of one of Jason‘s pics from Gnomedex this summer:

I wonder how the audience pics at DevConnections (.NET conference in vegas 2 weeks ago) compare.  Now, why didn’t I buy Apple stock when I first started noticing the geeks and their MBP or PBs back then?

New challenge – Web Reviews

I’ve got a new moonlighting gig, to go along with my own projects. I’m writing web reviews for Digital Trends. I didn’t really see this one coming but the opportunity seemed like an excellent one, so I’m giving it my best shot.

Digital Trends is one of the best web business stories in the Portland area. Founded just a few years ago, it has bootstrapped its way to a thriving online business focusing on consumer electronics reviews and news. Through the power networking group known as “mom’s groups,” I met Ian, the CEO, and after a few discussions about the latest TechCrunch reviews, I asked, “hey, why don’t you guys do web reviews, seems like a great fit for the current audience.” Next thing you know, I’m the one writing them.

My goals with these reviews are different than with a typical “Web 2.0 blog.” I don’t care about the latest breaking news, funding, the latest gossip, the business model, who the founders are, or anything like that. I’m only concerned with the site itself, and that’s what I focus on. How useful it is to the web audience. The site must at least be a public beta too, no private, invitation only ones. It needs to be ready for anybody to use it. The hardest part is picking, with so many sites to choose from. I make my picks on mainly a gut feel when I see the site, that “this is interesting.”

You may have also heard me rail against the Web 2.0 blogs posting so often, making it too difficult to keep up, and so my goal is to write 1 and maybe 2 a week. My inspiration comes more from the Solution Watch approach. The audience at Digital Trends is much more diverse though, so it’s fun to distill the great stuff we early adopters come across to a wider group of people.

The first batch went live a couple weeks ago. Take a look. I’d love to hear what you think, good and bad.

I welcome any submissions. My email is over there in the right-hand column. I can’t promise a response, but I will promise at least a look at your site.

Infrequent Round-up

When there’s some down time it’s nice to get a post out and then not worry about keeping up with the latest goings-on throughout the week so much here. I’ve pretty much gone the Twitter route for a lot of stuff I may have tried to turn into a post before. You can follow me there if you’re so inclined.

Local Signal
Had a couple days to myself last week and was able to wrap up a number of loose ends with Local Signal. First, I implemented session tracking, so items are bold if they are new since the last time you visited the page. Second, I fixed some bugs with the click tracking. I was using an AJAX call in the link’s onclick event, making it completely unobtrusive and not having to resort to those ugly redirect URLs. You can actually see the link when hovering over. Problem was that the AJAX handler was not getting the call in time, before the the browser followed the link. It only worked when opening a link in a new tab or window. Moving the AJAX call to the onmousedown event of the link fixed that. So, that enabled the “popular” pages to be completed. Only, nothing is really popular enough yet to be of very much use, so they’re hiding out at the moment. You can tack on “popular” as the page (in lieu of news, biz or the others) if you’re really curious.

The home page is the only outstanding item at this point before I start pimping it out to a larger audience. Content will continue to evolve as well, but it looks like there are a number of people checking the Portland news page daily, as that page along accounts for half the traffic to the site. I’m contemplating some type of local editor program to have a local representative in each city to provide the best sources and help publicize it.

Despite being on auto-pilot as I worked on Local Signal, we had our 2nd biggest traffic event ever this week, adding several hundred new users. The Australian news portal ran a great article on why and how people are using NetworthIQ to help improve their finances. The community is still growing strong and has really taken hold without me really doing anything, which is cool to see. I still have a todo list a mile long, but at least it will still be there when I come back around to building it out. In the coming weeks I really need to focus in on the revenue model beyond low paying ad networks, adsense, and link ads. That may actually involve doing some real market research and talking to people *gasp*. While I still got a kick out of seeing the traffic come, and the exposure is great, the rush was nowhere near when the NY Times article ran a couple years ago (can’t believe it’s been that long). A big reason for that is that it really only means literally a few dollars more in my pocket and I know it’s not really going to do a whole lot to put me in a place where I can work on it full-time. It needs to be where when one of those hits, it will mean significant revenue.

The site also got hit by the big Google crack-down on paid links, with our PageRank going from 5 to 3. Organic google traffic accounts for 20% of overally referrers so it’s not something to take lightly, but the drop so far has not revealed a corresponding drop in our SERP rankings.

Ignite Portland

Unless you were living under a rock, or not in Portland, it was hard to miss this week’s big event. Todd and I headed down there and I really enjoyed it. I knew 4 of the presenters, so it was cool to see them do well and I thought pretty much all of the speakers did great. It was also nice to see many familiar faces from PDXWI there. Looking forward to the next one.

The only thing I can remember disagreeing the whole night was the Les Schwab bit. I think they had good service a couple years ago, but the last few times I’ve been there, I’ve been tremendously disappointed at the service and the workmanship (I waited an hour to get a new battery, only for them to tell me it was fine, when I knew for a fact it wasn’t and had to get it replaced soon after elsewhere). I think they’re losing their way, but they have tremendous goodwill still, so it may let them thrive anyway. Despite this, I’m not disagreeing with Scott’s premise, I’d love to see more services from a gas station, but gas and tires are different animals (gas being more cost-sensitive since we buy it more frequently).