-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use fast's jsonparser #14
Comments
This could be solved if I had implemented some sort of parser "snapshotting". But right now there is no way to get back to the start of the CVE item, once you reach the "ID". I see the use case and it makes sense to implement something like |
All that really needs to be saved and restored is |
Example usage: import fast.json;
import std.stdio;
struct CVE {
string data_type;
string data_format;
string data_version;
CVEMeta CVE_data_meta;
}
struct CVEMeta {
string ID;
string ASSIGNER;
}
void main() {
bool[string] shoppingList = ["CVE-2017-0006":true, "CVE-2017-9999":true];
with (parseJSONFile("nvdcve-1.0-2017.json")) {
foreach (n; CVE_Items) {
with (cve) {
const backup = state;
const id = CVE_data_meta.ID.borrowString();
if (id in shoppingList) {
state = backup;
writeln(json.read!CVE());
}
}
}
}
} Runs @ ~1100 MiB/s for me when compiled with LDC2. (4th gen i5 @ 2.3 Ghz, DDR3) |
wow ... thanks a lot ... will give this a try, at the moment i am still struggling in getting uncompressed data into dlang (i do not even reach java speed right now for gzipped data). |
two more questions :)
|
So you need fast.gzip as well? ;-) (Maybe the system zlib is faster when linked into your D program than Phobos.) |
Thanks again. I will look into the gzip thing and also look how to work with the subtrees! Happy new year! |
Hi Marco, I really like the speed that comes with your pull based approach.
I have a simple program, that I would like to implement, but I am struggling applying the pull based thing to the problem:
I want to analyse nist's cve data (https://nvd.nist.gov/vuln/data-feeds) e.g. by searching through a datafile and printing out the whole json entry that matches an id.
The datalooks like this:
with your nice library I can easily write something like this:
But instead of just outputting the id, i would like to dump everything, that belongs to the object that contains the matching id.
Whats the best way to do this?
The text was updated successfully, but these errors were encountered: