Skip to content

Instantly share code, notes, and snippets.

@uiur
Created August 21, 2015 08:06
Show Gist options
  • Save uiur/322f9a83cd549e5ddf93 to your computer and use it in GitHub Desktop.
Save uiur/322f9a83cd549e5ddf93 to your computer and use it in GitHub Desktop.
var qwery = require('qwery')
var unescape = require('lodash/string/unescape')
module.exports = function () {
return qwery('script[type="application/json"]').reduce(function (obj, el) {
var key = el.getAttribute('data-key')
if (key) {
try {
obj[key] = JSON.parse(unescape(el.textContent))
} catch (e) {
}
}
return obj
}, {})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment