mongo-ejson 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +35 -1
- data/Rakefile +1 -1
- data/lib/ejson/version.rb +1 -1
- data/{lib/assets → vendor/assets/javascripts}/ejson.js +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fe75002ec17489608405072b1cf5e19643bce4732f97fc74c42a7d4c77f331a
|
4
|
+
data.tar.gz: 9ffd4f54c57599d7c97081f6fdf7ee27bd3075bb7ae95cf659910d9e20f1a8af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4def483883272fd0938a362fd6edd41131f4b9e633aefca1ab3b2f793f9078730eb0026e0010cc602c4152b68faa52a02edb790bef5a6951a714880d32135c9a
|
7
|
+
data.tar.gz: 17cf8d185b2dcfa62e654b6752cba2f0ebd4eba6c0e2665b98117b19698c72786f035ed23f950d4b9abe059c2f4d38527587c12276487ddb9e57ca2e8180c38d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,44 @@
|
|
1
1
|
# mongo-ejson
|
2
2
|
|
3
|
-
[](https://travis-ci.org/db-ai/mongo-ejson)
|
3
|
+
[](https://travis-ci.org/db-ai/mongo-ejson) [](https://badge.fury.io/rb/mongo-ejson)
|
4
4
|
|
5
5
|
This is a parser for mongo "flavoured" JSON, that supports mongo specific literals like `ISODate` or `ObjectId`, as well as some other nasty non-json things.
|
6
6
|
|
7
7
|
It can instantiate corresponding BSON objects or produce Extended JSON objects.
|
8
8
|
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Add gem to your Gemfile:
|
12
|
+
|
13
|
+
gem 'mongo-ejson'
|
14
|
+
|
15
|
+
Require when needed:
|
16
|
+
|
17
|
+
require 'ejson'
|
18
|
+
|
19
|
+
You can parse files in two modes: `Wrap` and `BSON`.
|
20
|
+
|
21
|
+
In `Wrap` mode, parser will instantiate Struct classes. It's useful when you
|
22
|
+
only need to validate provided EJSON code.
|
23
|
+
|
24
|
+
EJSON.parse_wrap(%q|{ "_id": ObjectId('5c520a538628ea8c13261c64') }|)
|
25
|
+
=> {"_id"=>#<struct Struct::ObjectId hex="5c520a538628ea8c13261c64">}
|
26
|
+
|
27
|
+
To use `BSON` mode you need to install `bson` gem. In this case parser will
|
28
|
+
instantiate real BSON objects.
|
29
|
+
|
30
|
+
require 'bson'
|
31
|
+
EJSON.parse_bson(%q|{ "_id": ObjectId('5c520a538628ea8c13261c64') }|)
|
32
|
+
=> {"_id"=>BSON::ObjectId('5c520a538628ea8c13261c64')}
|
33
|
+
|
34
|
+
You can also use JavaScript parser in your Rails application. At the moment it
|
35
|
+
does not build JavaScript object and returns raw parse tree. It is useful only
|
36
|
+
for validating the syntax.
|
37
|
+
|
38
|
+
Just add it to your `application.js`
|
39
|
+
|
40
|
+
//= require 'ejson'
|
41
|
+
|
9
42
|
## Requirements
|
10
43
|
|
11
44
|
Runtime:
|
@@ -42,6 +75,7 @@ Development:
|
|
42
75
|
|
43
76
|
## Planned JSON extensions:
|
44
77
|
|
78
|
+
* Non-quoted key names: `{_id: 123}`
|
45
79
|
* Multi-line comments: `/* */`
|
46
80
|
|
47
81
|
## Issues
|
data/Rakefile
CHANGED
data/lib/ejson/version.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo-ejson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Bondar
|
@@ -83,7 +83,6 @@ files:
|
|
83
83
|
- bin/console
|
84
84
|
- bin/setup
|
85
85
|
- ejson.gemspec
|
86
|
-
- lib/assets/ejson.js
|
87
86
|
- lib/ejson.rb
|
88
87
|
- lib/ejson/parser_action/abstract.rb
|
89
88
|
- lib/ejson/parser_action/abstract_json.rb
|
@@ -97,6 +96,7 @@ files:
|
|
97
96
|
- lib/ejson/version.rb
|
98
97
|
- src/ejson.peg
|
99
98
|
- src/ejson.rb
|
99
|
+
- vendor/assets/javascripts/ejson.js
|
100
100
|
homepage: https://gibhub.com/db-ai/mongo-ejson
|
101
101
|
licenses: []
|
102
102
|
metadata:
|