0

Given some JSON value and a query in MongoDB format, I want to filter the same way that MongoDB does, the json entities I want without going to the MongoDB.

For example, I have:

JSON Value: [{qty: 10}, {qty: 30}, {qty: 50}] Query in MongoDB format: { qty: { $gt: 20 } }

Result: [{qty: 50}]

I want that without going to Mongo database, for example calling some method that recives JSON Value and JSON Query String in Mongo format, inside some JAR.

Thanks!

gonzalomelov
  • 971
  • 1
  • 13
  • 30

2 Answers2

1

I want that without going to Mongo database

Parse JSON using Jackson and create a Query Object and a Collection containing the target objects.

Use a collections framework such as Guava or GS-Collections and filter.

Community
  • 1
  • 1
Ajay George
  • 11,759
  • 1
  • 40
  • 48
0

'Jackson' library offers JSON parsing & generation in Java. Once you've parsed, you can filter values/ data structure using Java code to your heart's content.

Java obviously has no direct implementation of Mongo query language.. you can implement Java code yourself as desired.

See:

Thomas W
  • 13,940
  • 4
  • 58
  • 76