0

I have document structure like:

    { "_id": { "$oid" : "51711cd87023380037000001" }, 
    "dayData": "{ "daysdata":{"date":"02-12-2013","week_day":"","month":"","date_day":"","year":"2013"}}" 
    }

I want to extract document having date = "02-12-2013" in the above. Here i am trying to query on a value which is also a json. Please let me know how to use mongodb java driver to extract this

dsr301
  • 759
  • 3
  • 7
  • 21
  • Are you fetching data from JSON or MongoDB ? – Srivatsa N Apr 22 '13 at 08:17
  • i am fetching data from mongodb. This is the document structure stored in mongodb. – dsr301 Apr 22 '13 at 08:27
  • Is the `dayData` field really a JSON string? – MervS Apr 24 '13 at 05:22
  • I would suggest that in your application, you parse the JSON string to extract the objects and create a subdocument which you will put in the `dayData` field. Things would be much easier to query if that's the case. – MervS Apr 24 '13 at 06:03
  • Or, why don't you just save the only `date` in ISO format is a single field like `"dayData" : ISODate(...)`. Day, month, etc. values will be easy to compute. – MervS Apr 24 '13 at 06:14

1 Answers1

0

Not answer (stackoverflow won't let me comment as I don't have enough points!)

Your string containing json has a syntax error. There is a single " after "year":"2013"

You may have to fix that 1st.

ranjjose
  • 2,138
  • 1
  • 24
  • 46