Created
November 19, 2019 00:52
-
-
Save stopdropandrew/6ee9e8147d5961604a2fca80d99ef076 to your computer and use it in GitHub Desktop.
convert adb content query output to json
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
#!/usr/bin/env ruby | |
require 'json' | |
results = `adb shell content query #{ARGV.join(' ')}` | |
lines = results.split("\n") | |
rows = lines.map do |line| | |
match = line.match(/Row: \d+ (.*)/) | |
next unless match | |
args = match[1].split(", ").map{|a| a.split("=")}.map {|arg| [arg.first, arg.last == "NULL" ? nil : arg.last]}.to_h | |
end.compact | |
puts rows.to_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment