Created
December 12, 2016 11:33
-
-
Save fluency03/bba70587f8d4c8cb3012ef9a2aa96e47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'json' | |
| def parse_array obj, top, event | |
| if obj.is_a? Array | |
| obj.each_with_index {|oo, ii| | |
| parse_json_array(oo, ii, top, event) | |
| } | |
| end | |
| end | |
| def parse_json_array obj, i, top, event | |
| obj = JSON.parse(obj) unless obj.is_a? Hash | |
| top_ = top | |
| if obj.is_a? Hash | |
| k = obj['name'] | |
| v = obj['value'] | |
| p = [top_, k].join('.') | |
| event.set(p, v) | |
| else | |
| event.set(top_, obj) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment