This is a follow-up question to this question:
getPathValue() function for deep objects
I NEED TO KEEP ALL OF THE FUNCTIONALITY OF THE ORIGINAL SOLUTION:
function getPathValue(object, path) {
return path
.match(/[^[\].]+/g)
.reduce(function (o, k) {
return (typeof o === 'string' ? JSON.parse(o) : (o || {}))[k];
}, object);
}
I would like to modify this function so that it can handle a particular type of array and return MULTIPLE values, separated by commas.
Here is the sample object:
{"MSFT":{"company":{"symbol":"MSFT","companyName":"Microsoft Corporation","exchange":"Nasdaq Global Select","industry":"Application Software","website":"http://www.microsoft.com","description":"Microsoft Corp is a technology company. It develop, license, and support a wide range of software products and services. Its business is organized into three segments: Productivity and Business Processes, Intelligent Cloud, and More Personal Computing.","CEO":"Satya Nadella","issueType":"cs","sector":"Technology","tags":["Technology","Software - Infrastructure","Application Software"]}},"T":{"company":{"symbol":"T","companyName":"AT&T Inc.","exchange":"New York Stock Exchange","industry":"Communication Services","website":"http://www.att.com","description":"AT&T Inc is engaged in provision of communications and digital entertainment services in the United States and the world. It provides fixed-line services, including voice, data, and television services to consumers and small businesses.","CEO":"Randall L. Stephenson","issueType":"cs","sector":"Communication Services","tags":["Communication Services","Telecom Services"]}},"GE":{"company":{"symbol":"GE","companyName":"General Electric Company","exchange":"New York Stock Exchange","industry":"Industrial Products","website":"http://www.ge.com","description":"General Electric Co is a digital industrial company. It operates in various segments, including power and water, oil and gas, energy management, aviation, healthcare, transportation, appliances and lighting, and more.","CEO":"H. Lawrence Culp","issueType":"cs","sector":"Industrials","tags":["Industrials","Diversified Industrials","Industrial Products"]}},"FB":{"company":{"symbol":"FB","companyName":"Facebook Inc.","exchange":"Nasdaq Global Select","industry":"Online Media","website":"http://www.facebook.com","description":"Facebook Inc is the world's largest online social network. Its products are Facebook, Instagram, Messenger, WhatsApp, and Oculus. Its products enable people to connect and share through mobile devices and personal computers.","CEO":"Mark Zuckerberg","issueType":"cs","sector":"Technology","tags":["Technology","Internet Content & Information","Online Media"]}},"AAPL":{"company":{"symbol":"AAPL","companyName":"Apple Inc.","exchange":"Nasdaq Global Select","industry":"Computer Hardware","website":"http://www.apple.com","description":"Apple Inc is designs, manufactures and markets mobile communication and media devices and personal computers, and sells a variety of related software, services, accessories, networking solutions and third-party digital content and applications.","CEO":"Timothy D. Cook","issueType":"cs","sector":"Technology","tags":["Technology","Consumer Electronics","Computer Hardware"]}},"NKE":{"company":{"symbol":"NKE","companyName":"Nike Inc.","exchange":"New York Stock Exchange","industry":"Manufacturing - Apparel & Furniture","website":"http://www.nike.com","description":"Nike Inc designs, develops and markets footwear, apparel, equipment, and accessory products. It is a seller of athletic footwear and athletic apparel. It sells its products through NIKE-owned in-line and factory retail stores and internet websites.","CEO":"Mark G. Parker","issueType":"cs","sector":"Consumer Cyclical","tags":["Consumer Cyclical","Footwear & Accessories","Manufacturing - Apparel & Furniture"]}},"KO":{"company":{"symbol":"KO","companyName":"Coca-Cola Company (The)","exchange":"New York Stock Exchange","industry":"Beverages - Non-Alcoholic","website":"http://www.coca-colacompany.com","description":"Coca-Cola Co is nonalcoholic beverage company which manufactures a variety of carbonated and noncarbonated brands, including Coca-Cola, Diet Coke, Fanta, Sprite, Minute Maid, Powerade, and Dasani.","CEO":"James Robert Quincey","issueType":"cs","sector":"Consumer Defensive","tags":["Consumer Defensive","Beverages - Soft Drinks","Beverages - Non-Alcoholic"]}},"IBM":{"company":{"symbol":"IBM","companyName":"International Business Machines Corporation","exchange":"New York Stock Exchange","industry":"Application Software","website":"http://www.ibm.com","description":"International Business Machines Corp offers a variety of IT services along with software, and hardware. It has operations in over 170 countries and provides planning, build, manage, and maintain IT infrastructure, platforms, applications, and services.","CEO":"Virginia M. Rometty","issueType":"cs","sector":"Technology","tags":["Technology","Information Technology Services","Application Software"]}},"V":{"company":{"symbol":"V","companyName":"Visa Inc.","exchange":"New York Stock Exchange","industry":"Credit Services","website":"http://www.corporate.visa.com","description":"Visa Inc is a payments technology company working to enable consumers, businesses, banks and governments to use fast, secure and reliable digital currency. The Company operates processing networks - VisaNet.","CEO":"Alfred F. Kelly","issueType":"cs","sector":"Financial Services","tags":["Financial Services","Credit Services"]}},"AXP":{"company":{"symbol":"AXP","companyName":"American Express Company","exchange":"New York Stock Exchange","industry":"Credit Services","website":"http://www.americanexpress.com","description":"American Express Co is a payments, network and travel company. It provides charge and credit card products, travel services, network services, stored value products, loans, and other products and services to businesses and individuals.","CEO":"Stephen J. Squeri","issueType":"cs","sector":"Financial Services","tags":["Financial Services","Credit Services"]}}}
I would like to pass a path string something like this:
ceoList = getPathValue(obj, '*.company.CEO');
...and the returned value would look like this:
Satya Nadella,Randall L. Stephenson,H. Lawrence Culp,Mark Zuckerberg,Timothy D. Cook,Mark G. Parker,James Robert Quincey,Virginia M. Rometty,Alfred F. Kelly,Stephen J. Squeri
IMPORTANT: the solution must remain ES5 compatible and specifically, IE11 compatible.
EDIT:
Unless I am missing something, this is NOT a duplicate. Please show a solution for the stated problem.