From a4d12c26c7e1ba7e2033fbff533356b1d7dbfb08 Mon Sep 17 00:00:00 2001 From: Dmitry Ivanov Date: Mon, 16 Dec 2019 21:41:57 +0100 Subject: [PATCH] Make chrome:tracing importer support both array and object forms of input. --- import-chrome/src/import-chrome.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/import-chrome/src/import-chrome.cpp b/import-chrome/src/import-chrome.cpp index 2e3a41c2..d1670210 100644 --- a/import-chrome/src/import-chrome.cpp +++ b/import-chrome/src/import-chrome.cpp @@ -56,6 +56,17 @@ int main( int argc, char** argv ) std::vector timeline; std::vector messages; + if( j.is_object() && j.contains( "traceEvents" ) ) + { + j = j["traceEvents"]; + } + + if( !j.is_array() ) + { + fprintf( stderr, "Input must be either an array of events or an object containing an array of events under \"traceEvents\" key.\n" ); + exit( 1 ); + } + for( auto& v : j ) { const auto type = v["ph"].get();