Skip to content
/ jason Public

simple json parser with JSON Path ike query system.

Notifications You must be signed in to change notification settings

sijirama/jason

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stupid simple json parser in zig

if this is the worst zig code you've ever seen please create pointers as issues, this is my frist zig project to know how the language works and i plan on mainstreaming it for a while, so please let me know where you thought the code was outrageous and what you think can be better.

important reads i think

i want to try and implement this

const testJSONObject = `{
    "item1": ["aryitem1", "aryitem2", {"some": {"thing": "coolObj"}}],
    "item2": "simplestringvalue"
}`

c, err := dora.NewFromString(testJSONObject)
if err != nil {
    fmt.Printf("\nError creating client: %v\n", err)
}

result, err := c.GetByPath("$.item1[2].some.thing")
if err != nil {
    fmt.Println(err)
}

inspired from here

a week later and yh i did it.

pub fn main() !void {
    const json_string =
        \\{ "store": { "book": [
        \\  { "title": "Book 1" },
        \\  { "title": "Book 2" },
        \\  { "title": "Book 3" },
        \\  { "title": "Book 4" }
        \\] } }
    ;

    const allocator = std.heap.page_allocator;

    var jason = Jason.init(allocator, json_string);

    const queried = try jason.query("$.store.book[3].title");

    jason.printValue(queried); // "Book 4"
}

the code became even more worse, sorry about that, i'm just learning zig, but good news is i like it and i'm gonna keep using it.

About

simple json parser with JSON Path ike query system.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages