www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Is there such a JSON parser?

reply torhu <torhu yahoo.com> writes:
I need to parse some JSON data into various data structures, so 
I'm looking for a parser based on events or ranges. One that 
doesn't just load the file and build a data structure that 
represents the whole thing. So not std.json, at least.
Jan 01 2023
next sibling parent Salih Dincer <salihdb hotmail.com> writes:
On Sunday, 1 January 2023 at 23:28:12 UTC, torhu wrote:
 I need to parse some JSON data into various data structures, so 
 I'm looking for a parser based on events or ranges. One that 
 doesn't just load the file and build a data structure that 
 represents the whole thing. So not std.json, at least.
There may be suggestions that will come in handy in a discussion that here: https://forum.dlang.org/thread/wtnxglafyxhscspqcdwj forum.dlang.org SDB 79
Jan 01 2023
prev sibling next sibling parent reply thebluepandabear <therealbluepandabear protonmail.com> writes:
On Sunday, 1 January 2023 at 23:28:12 UTC, torhu wrote:
 I need to parse some JSON data into various data structures, so 
 I'm looking for a parser based on events or ranges. One that 
 doesn't just load the file and build a data structure that 
 represents the whole thing. So not std.json, at least.
I'm new to D and also haven't found any solid JSON libraries. Unfortunately a massive downside for D is the fact that the ecosystem is very small when compared to other languages such as Java. You might want to try the following: https://github.com/libmir/asdf
Jan 01 2023
parent torhu <torhu yahoo.com> writes:
On Monday, 2 January 2023 at 05:44:33 UTC, thebluepandabear wrote:
 You might want to try the following:

 https://github.com/libmir/asdf
I had a look at that, but I think it just loads the whole file into it's own data structure. And then you can use attributes to get it to fill structs with data, but that's too basic for my needs.
Jan 02 2023
prev sibling next sibling parent reply SealabJaster <sealabjaster gmail.com> writes:
On Sunday, 1 January 2023 at 23:28:12 UTC, torhu wrote:
 I need to parse some JSON data into various data structures, so 
 I'm looking for a parser based on events or ranges. One that 
 doesn't just load the file and build a data structure that 
 represents the whole thing. So not std.json, at least.
Are you asking for a SAX-styled parser for JSON? Similarly - what would you like to see from a full-featured JSON module? For context: I'm currently (very slowly) working on a -betterC library. The JSON lexer is able to work off of buffered data streams instead of flat in-memory arrays. So even if what you're looking for doesn't exist right now, I'd like to try and (again; very slowly) change that.
Jan 02 2023
next sibling parent torhu <torhu yahoo.com> writes:
On Monday, 2 January 2023 at 14:56:27 UTC, SealabJaster wrote:
 Are you asking for a SAX-styled parser for JSON?
Yes, I actually want to replace a SAX parser.
Jan 02 2023
prev sibling parent Chris Piker <chris hoopjump.com> writes:
On Monday, 2 January 2023 at 14:56:27 UTC, SealabJaster wrote:

 Are you asking for a SAX-styled parser for JSON?
I have an upcoming project (about 3-6 months away) that could make use of this as well. If you need someone to try it out please let me know and I'll give it a spin. Good luck on your library. Cheers,
Jan 02 2023
prev sibling parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 1/1/23 6:28 PM, torhu wrote:
 I need to parse some JSON data into various data structures, so I'm 
 looking for a parser based on events or ranges. One that doesn't just 
 load the file and build a data structure that represents the whole 
 thing. So not std.json, at least.
It's pretty rough-edged, but https://code.dlang.org/packages/jsoniopipe will do this. It has mechanisms to jump to specific object members, and to rewind to a cached point. It does not use any intermediate representation. -Steve
Jan 02 2023
parent torhu <torhu yahoo.com> writes:
On Monday, 2 January 2023 at 21:36:10 UTC, Steven Schveighoffer 
wrote:
 On 1/1/23 6:28 PM, torhu wrote:
 I need to parse some JSON data into various data structures, 
 so I'm looking for a parser based on events or ranges. One 
 that doesn't just load the file and build a data structure 
 that represents the whole thing. So not std.json, at least.
It's pretty rough-edged, but https://code.dlang.org/packages/jsoniopipe will do this. It has mechanisms to jump to specific object members, and to rewind to a cached point. It does not use any intermediate representation. -Steve
Thank, I can check it out.
Jan 02 2023