Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Best practice to transform JSON with MongoDB
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
D Boyd  
View profile  
 More options Nov 1 2010, 7:39 pm
From: D Boyd <db...@data-tactics.com>
Date: Mon, 1 Nov 2010 16:39:46 -0700 (PDT)
Local: Mon, Nov 1 2010 7:39 pm
Subject: Best practice to transform JSON with MongoDB
Greetings all:
      I am pretty new to Mongo and had a question I hope the group can
help with.

I have a number of records in the DB now, that I would like to
transform server side from their
current structure into a GeoJSON compliant structure.
Basically, the records are of the form:

{ id: "id1", att1: "att value", att2: "att 2 value", lat: "34.33",
lon: "22.34" }

I need to transform that into GeoJSON of the form:

{ "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          [22.34, 34.33]
          ]
        },
      "properties": {
        "att1": "att value",
        "att2": "att 2 value"
        }
 }

In my searches I found a couple of interesting Javascript functions
(jsonT, jsonPath) at http://goessner.net/articles/JsonPath/

I have successfully stored them inside my mongo instance and was even
able from the console to execute jsonPath on a result set.
However the whole syntax with db.eval is klunky and I have read about
issues with
it blocking the database.

There are several brute force approaches that can be written in
javascript or java to do the work but
before I tackled those I thought I would ask the list if there was
some best practice or more elegant
approach.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kyle Banker  
View profile  
 More options Nov 3 2010, 10:33 am
From: Kyle Banker <k...@10gen.com>
Date: Wed, 3 Nov 2010 10:33:47 -0400
Local: Wed, Nov 3 2010 10:33 am
Subject: Re: [mongodb-user] Best practice to transform JSON with MongoDB
I think that the fastest and best approach here would be to query your
collection in batches, transform using Java, and then bulk-insert into
a new collection.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »