jquery count items in json
<p>I have a JSON that looks like this:</p>

<pre><code>({
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "properties": {
                "wkb_geometry": null,
                "code": "type 1",
                "code2": "type 3",
                "code3": "type 5",
                "updated_at": "2012-10-29T12:38:00.037Z"
            }, 
        },
        {
            "type": "Feature",
            "properties": {
                "wkb_geometry": null,
                "code": "type 1",
                "code2": "type 5",
                "code3": "type 7",
                "updated_at": "2012-10-29T12:38:00.037Z"
            },

        },
        {
            "type": "Feature",
            "properties": {
                "wkb_geometry": null,
                "code": "type 2",
                "code2": "type 3",
                "code3": "type 5",
                "activity_type": "children's play area",
                "updated_at": "2012-10-29T12:38:00.037Z"
            },

        }...
</code></pre>

<p>Basically I want to count all the codes in this Json i.e. there are 3 occurrences of type 5.</p>

<p>So far I have a loop that picks out all the type 1 codes, but I am not sure how to get the loop to count the items:</p>

<pre><code>$.each(geojson.features, function(i, v) {
    if (v.properties.code.search(new RegExp(/type 1/i)) != -1) {
        console.log(v.properties.activity_type_code);
    }
});
</code></pre>
