Skip to content

FCO/JSON-Stream

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
t
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Build Status

JSON::Stream

A JSON stream parser

use JSON::Stream;
react whenever json-stream "a-big-json-file.json".IO.open.Supply, '$.employees.*' -> (:$key, :$value) {
    say "$key => $value<name> - $value<age>"
}

# OUTPUT:
# $.employees.0 => John - 40
# $.employees.1 => Peter - 30

Having this as an example of 'a-big-json-file.json'

{
    "employees": [
        { "name": "John",  "age": 40 },
        { "name": "Peter", "age": 30 }
    ]
}

Warning

It doesn't validate the JSON. That's good for cases where the JSON isn't properly terminated. Example:

react whenever json-stream Supply.from-list(< { "bla" : [1,2,3,4], >), '$.bla.*' -> (:key($), :$value) {
   say $value
}

# OUTPUT:
# 1
# 2
# 3
# 4

sub json-stream

sub json-stream(
    Supply $supply,
    +@subscribed
) returns Supply

Receives an supply and a list of simplified json-path strings

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages