Skip to content

Instantly share code, notes, and snippets.

@wsmoak
Created November 12, 2014 15:04
Show Gist options
  • Save wsmoak/31b79efedbbdfe2cdd61 to your computer and use it in GitHub Desktop.
Save wsmoak/31b79efedbbdfe2cdd61 to your computer and use it in GitHub Desktop.
I started with
{ :weight => 2.24, :count => 2, :date => to_utc(2014,11,10), :notes => "" }
then
{ :weight => 1.14, :date => to_utc(2014,11,10), :notes => "" }
{ :weight => 1.10, :date => to_utc(2014,11,10), :notes => "" }
But I only want one "thing" for each date, with the details stored inside. I tried:
litters.insert(
{:id => "43", :doe => "3BL", :buck => "C16", :birth_date => to_utc(2014,10,24),
:kindled => 2, :survived => 2,
:weights => [
{ :date => to_utc(2014,11,10),
:avg_weight => 1.12,
:count => 2,
:data => [
{ :weight => 1.14, :id => "", :notes => "" },
{ :weight => 1.10, :id => "", :notes => "" }
]
}
]
}
)
But that gives:
load.rb:56: syntax error, unexpected {, expecting ']'
{ :weight => 1.10, :id => "", :notes => "" }
^
load.rb:57: syntax error, unexpected ']', expecting end-of-input
The whole thing is here: https://github.com/wsmoak/nivens/blob/master/mongo-ruby/load.rb
Looking at http://www.json.org at the definition of an array ... what am I doing wrong?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment