Comments (4)
@chhex Thanks for using JsonDB and taking the time to report this issue.
Yes, this is a problem. Its easier to deal with the files if one line of data is treated as just one row/document. but as you highlighted editing these .json files is not really user-friendly. And I have often thought of ways to fix this, but never could determine the best way. A few ways I think this can be fixed:
- Accept a setting for
pretty-read=true
and then expect the files to be formatted for readability then parse for}
which is not followed by a,
and break the rows at that point. - Additionally accept a setting for
pretty-print=true
and then when saving the files format them accordingly - OR accept a setting
lines-per-row
and then parse the file readinglines-per-row
each time
Could you maybe suggest more ways to do this or your view on this.
Could other users of JsonDB maybe suggest ways to fix this. I will be happy to fix this if I have some feedback.
from jsondb-core.
@FarooqKhan best thanks for your time and consideration.
I agree it's not a trivial problem. I think your suggestions are helpful.
How about only the pretty-print=true option and then jsondb can make assumptions that the formatting is left unchanged? At least for a start.
That said: i have to try it out to give you definite feedback. I would be happy to try it out.
from jsondb-core.
@FarooqKhan @chhex
What if the internal representation of the collection is a bit different?
Instead of having:
{"schemaVersion":"1.0"}
{"id":"x", "field":"y"}
{"id":"a", "field":"b"}
have something like
{
"schemaVersion": "1.0",
"items" : [
{"id":"x", "field":"y"},
{"id":"a", "field":"b"}
]
}
Since the latter json is in correct form, it does not matter whether you pretty-print it or not.
Yes, it does add two levels of nesting, but on the other hand using any json parser is possible.
Also, this form allows you to insert as much metadata (like storing indexes) as you want and easily parse it back later.
PS: I can see that having an item per line somewhat speeds up the reading-writing-parsing from the file.
from jsondb-core.
@chhex
I created a Atom Editor plugin to solve this problem that you are facing jsondb-atom-plugin.
The plugin is work in progress but should be usable as it is now.
If you get some time try using it, I would appreciate any feedback you have about the plugin.
I know its a special way of editing these files but I think this is much simpler way to solve this problem then making Jsondb itself handle the formatting, I suspect it will make Jsondb slow and code will take time to perfect
from jsondb-core.
Related Issues (20)
- Generated resources during test execution not deleted afterwards
- No way to "flush" database HOT 2
- Provide security contact info HOT 2
- Modified json file make collectionExist return false HOT 2
- Android does not find any classes HOT 2
- Recursive data structures. Cycles not supported
- JDK 15 compliance
- jsonDBTemplate.findAll(Instance.class, comparator) HOT 4
- xpath lower-case() find. HOT 1
- ndjson parse example
- File Writes Are Not Thread Safe HOT 2
- invalid json format HOT 1
- No class found with @Document Annotation and attribute collectionName as: User, Android HOT 2
- Method for fast retrieval of collection size
- TURN OFF ERROR HANDLING IN MAVEN RELEASES, PLEASE
- Bug: Multiple SchemaUpdates (Rename) not possible
- One file for each item in a collection HOT 3
- Symlinks broken HOT 2
- getCollection always return the last item HOT 1
- Failed to acquire lock for collection file ClosedChannelException
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsondb-core.