Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MikeGrace/403249 to your computer and use it in GitHub Desktop.
Save MikeGrace/403249 to your computer and use it in GitHub Desktop.
ruleset a60x226 {
meta {
name "array inside an array"
description <<
for devex question
>>
author "Mike Grace"
logging on
}
dispatch { }
global {
exampleHash = {
"articles" : [
{
"title" : "Not sure what to title this",
"thumbs" : [
{ "url" : "http://geek.michaelgrace.org/MikeGrace.jpg" },
{ "url" : "http://geek.michaelgrace.org/is.jpg" },
{ "url" : "http://geek.michaelgrace.org/a.jpg" },
{ "url" : "http://geek.michaelgrace.org/fun.jpg" },
{ "url" : "http://geek.michaelgrace.org/guy.jpg" }
]
},
{
"title" : "Not going to change the images for this one",
"thumbs" : [
{ "url" : "http://geek.michaelgrace.org/MikeGrace.jpg" },
{ "url" : "http://geek.michaelgrace.org/is.jpg" },
{ "url" : "http://geek.michaelgrace.org/a.jpg" },
{ "url" : "http://geek.michaelgrace.org/fun.jpg" },
{ "url" : "http://geek.michaelgrace.org/guy.jpg" }
]
},
{
"title" : "Isn't Devex great?!",
"thumbs" : [
{ "url" : "http://geek.michaelgrace.org/MikeGrace.jpg" },
{ "url" : "http://geek.michaelgrace.org/is.jpg" },
{ "url" : "http://geek.michaelgrace.org/a.jpg" },
{ "url" : "http://geek.michaelgrace.org/fun.jpg" },
{ "url" : "http://geek.michaelgrace.org/guy.jpg" }
]
}
]
}
}
rule first_rule is active {
select using ".*" setting ()
foreach exampleHash.pick("$.articles") setting (article)
foreach article.pick("$.thumbs") setting (thumb)
pre {
title = article.pick("$.title");
thumbnail = thumb.pick("$.url");
}
notify(title,thumbnail) with width = 300 and sticky = true;
// end of foreach that iterates for each thumbnail in article
// end of foreach that iterates over each article
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment