You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use the multiple matching items qry but experiencing an issue at a certain level in the json hierarchy. It seems to be related to an array or arrays opposed to an array of objects as follows (sorry for the annoyingly long snippet of json but I want to make this as easy as possible to debug).
var jsonQuery =require("json-query")
var data = '{"name":"product","attributes":{},"isSelfClosing":false,"parent":null,"children":[" ",{"name":"sku","attributes":{},"isSelfClosing":false,"children":["17447336"]}," ",{"name":"productId","attributes":{},"isSelfClosing":false,"children":["2416800"]}," ",{"name":"name","attributes":{},"isSelfClosing":false,"children":["Invitation to Forever - CD"]}," ",{"name":"source","attributes":{},"isSelfClosing":false,"children":["bestbuy"]}," ",{"name":"type","attributes":{},"isSelfClosing":false,"children":["Music"]}," ",{"name":"startDate","attributes":{},"isSelfClosing":false,"children":["2008-04-22"]}," ",{"name":"new","attributes":{},"isSelfClosing":false,"children":["false"]}," ",{"name":"active","attributes":{},"isSelfClosing":false,"children":["true"]}," ",{"name":"lowPriceGuarantee","attributes":{},"isSelfClosing":false,"children":["true"]}," ",{"name":"activeUpdateDate","attributes":{},"isSelfClosing":false,"children":["2016-02-01T15:14:59"]}," ",{"name":"regularPrice","attributes":{},"isSelfClosing":false,"children":["13.99"]}," ",{"name":"salePrice","attributes":{},"isSelfClosing":false,"children":["13.99"]}," ",{"name":"onSale","attributes":{},"isSelfClosing":false,"children":["false"]}," ",{"name":"planPrice","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"priceWithPlan","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"advertisedPriceRestriction","attributes":{},"isSelfClosing":false,"children":["false"]}," ",{"name":"minimumDisplayPrice","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"restrictedSalePrice","attributes":{},"isSelfClosing":false,"children":["13.99"]}," ",{"name":"icrType","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"icrStartDate","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"icrEndDate","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"priceRestriction","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"priceUpdateDate","attributes":{},"isSelfClosing":false,"children":["2013-09-13T00:21:36"]}," ",{"name":"digital","attributes":{},"isSelfClosing":false,"children":["false"]}," ",{"name":"preowned","attributes":{},"isSelfClosing":false,"children":["false"]}," ",{"name":"outletCenter","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"secondaryMarket","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"frequentlyPurchasedWith","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"relatedProducts","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"crossSell","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"salesRankShortTerm","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"salesRankMediumTerm","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"salesRankLongTerm","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"bestSellingRank","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"url","attributes":{},"isSelfClosing":false,"children":["http://www.bestbuy.com/site/invitation-to-forever-cd/17447336.p?id=2416800&skuId=17447336&cmp=RMX"]}," ",{"name":"spin360Url","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"mobileUrl","attributes":{},"isSelfClosing":false,"children":["http://www.bestbuy.com/site/invitation-to-forever-cd/17447336.p?id=2416800&skuId=17447336&cmp=RMX&cmp=RMX"]}," ",{"name":"affiliateUrl","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"addToCartUrl","attributes":{},"isSelfClosing":false,"children":["http://www.bestbuy.com/site/olspage.jsp?id=pcmcat152200050035&type=category&cmp=RMX&qvsids=17447336"]}," ",{"name":"affiliateAddToCartUrl","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"linkShareAffiliateUrl","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"linkShareAffiliateAddToCartUrl","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"search","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"upc","attributes":{},"isSelfClosing":false,"children":["837792009887"]}," ",{"name":"productTemplate","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"categoryPath","attributes":{},"isSelfClosing":false,"children":[" ",{"name":"category","attributes":{},"isSelfClosing":false,"children":[" ",{"name":"id","attributes":{},"isSelfClosing":false,"children":["cat00000"]}," ",{"name":"name","attributes":{},"isSelfClosing":false,"children":["Best Buy"]}," "]}," ",{"name":"category","attributes":{},"isSelfClosing":false,"children":[" ",{"name":"id","attributes":{},"isSelfClosing":false,"children":["abcat0600000"]}," ",{"name":"name","attributes":{},"isSelfClosing":false,"children":["Movies & Music"]}," "]}," ",{"name":"category","attributes":{},"isSelfClosing":false,"children":[" ",{"name":"id","attributes":{},"isSelfClosing":false,"children":["cat02001"]}," ",{"name":"name","attributes":{},"isSelfClosing":false,"children":["Music (CDs & Vinyl)"]}," "]}," ",{"name":"category","attributes":{},"isSelfClosing":false,"children":[" ",{"name":"id","attributes":{},"isSelfClosing":false,"children":["cat02010"]}," ",{"name":"name","attributes":{},"isSelfClosing":false,"children":["Rock"]}," "]}," ",{"name":"category","attributes":{},"isSelfClosing":false,"children":[" ",{"name":"id","attributes":{},"isSelfClosing":false,"children":["cat02673"]}," ",{"name":"name","attributes":{},"isSelfClosing":false,"children":["Hard Rock"]}," "]}," "]}," ",{"name":"lists","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"customerReviewCount","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"customerReviewAverage","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"customerTopRated","attributes":{},"isSelfClosing":false,"children":["false"]}," ",{"name":"format","attributes":{},"isSelfClosing":false,"children":["CD"]}," ",{"name":"freeShipping","attributes":{},"isSelfClosing":false,"children":["false"]}," ",{"name":"freeShippingEligible","attributes":{},"isSelfClosing":false,"children":["true"]}," ",{"name":"inStoreAvailability","attributes":{},"isSelfClosing":false,"children":["false"]}," ",{"name":"inStoreAvailabilityText","attributes":{},"isSelfClosing":false,"children":["Store Pickup: Not Available"]}," ",{"name":"inStoreAvailabilityTextHtml","attributes":{},"isSelfClosing":false,"children":["<b>Store Pickup:</b> Not Available"]}," ",{"name":"inStoreAvailabilityUpdateDate","attributes":{},"isSelfClosing":false,"children":["2016-02-01T15:14:59"]}," ",{"name":"itemUpdateDate","attributes":{},"isSelfClosing":false,"children":["2016-02-17T05:22:50"]}," ",{"name":"onlineAvailability","attributes":{},"isSelfClosing":false,"children":["true"]}," ",{"name":"onlineAvailabilityText","attributes":{},"isSelfClosing":false,"children":["Shipping: Usually leaves our warehouse in 1 business day"]}," ",{"name":"onlineAvailabilityTextHtml","attributes":{},"isSelfClosing":false,"children":["<b>Shipping:</b> Usually leaves our warehouse in 1 business day"]}," ",{"name":"onlineAvailabilityUpdateDate","attributes":{},"isSelfClosing":false,"children":["2016-02-01T15:14:59"]}," ",{"name":"releaseDate","attributes":{},"isSelfClosing":false,"children":["2008-11-18"]}," ",{"name":"shippingCost","attributes":{},"isSelfClosing":false,"children":["2.99"]}," ",{"name":"shipping","attributes":{},"isSelfClosing":false,"children":[" ",{"name":"ground","attributes":{},"isSelfClosing":false,"children":["2.99"]}," ",{"name":"secondDay","attributes":{},"isSelfClosing":false,"children":["10.99"]}," ",{"name":"nextDay","attributes":{},"isSelfClosing":false,"children":["14.99"]}," ",{"name":"vendorDelivery","attributes":{},"isSelfClosing":true,"children":[]}," "]}," ",{"name":"shippingLevelsOfService","attributes":{},"isSelfClosing":false,"children":[" ",{"name":"shippingLevelOfService","attributes":{},"isSelfClosing":false,"children":[" ",{"name":"serviceLevelId","attributes":{},"isSelfClosing":false,"children":["1"]}," ",{"name":"serviceLevelName","attributes":{},"isSelfClosing":false,"children":["Standard"]}," ",{"name":"unitShippingPrice","attributes":{},"isSelfClosing":false,"children":["2.99"]}," "]}," ",{"name":"shippingLevelOfService","attributes":{},"isSelfClosing":false,"children":[" ",{"name":"serviceLevelId","attributes":{},"isSelfClosing":false,"children":["3"]}," ",{"name":"serviceLevelName","attributes":{},"isSelfClosing":false,"children":["Expedited"]}," ",{"name":"unitShippingPrice","attributes":{},"isSelfClosing":false,"children":["10.99"]}," "]}," ",{"name":"shippingLevelOfService","attributes":{},"isSelfClosing":false,"children":[" ",{"name":"serviceLevelId","attributes":{},"isSelfClosing":false,"children":["5"]}," ",{"name":"serviceLevelName","attributes":{},"isSelfClosing":false,"children":["Express"]}," ",{"name":"unitShippingPrice","attributes":{},"isSelfClosing":false,"children":["14.99"]}," "]}," "]}," ",{"name":"specialOrder","attributes":{},"isSelfClosing":false,"children":["false"]}," ",{"name":"shortDescription","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"shortDescriptionHtml","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"class","attributes":{},"isSelfClosing":false,"children":["COMPACT DISC"]}," ",{"name":"classId","attributes":{},"isSelfClosing":false,"children":["77"]}," ",{"name":"subclass","attributes":{},"isSelfClosing":false,"children":["ROCK"]}," ",{"name":"subclassId","attributes":{},"isSelfClosing":false,"children":["1001"]}," ",{"name":"department","attributes":{},"isSelfClosing":false,"children":["VIDEO/COMPACT DISC"]}," ",{"name":"departmentId","attributes":{},"isSelfClosing":false,"children":["8"]}," ",{"name":"bestBuyItemId","attributes":{},"isSelfClosing":false,"children":["1324170"]}," ",{"name":"productFamilies","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"manufacturer","attributes":{},"isSelfClosing":false,"children":["Prog Rock Records"]}," ",{"name":"image","attributes":{},"isSelfClosing":false,"children":["http://images.bestbuy.com/BestBuy_US/images/products/1744/17447336_sa.jpg"]}," ",{"name":"largeFrontImage","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"mediumImage","attributes":{},"isSelfClosing":false,"children":["http://images.bestbuy.com/BestBuy_US/images/products/1744/17447336fp.gif"]}," ",{"name":"thumbnailImage","attributes":{},"isSelfClosing":false,"children":["http://images.bestbuy.com/BestBuy_US/images/products/1744/17447336_s.gif"]}," ",{"name":"largeImage","attributes":{},"isSelfClosing":false,"children":["http://images.bestbuy.com/BestBuy_US/images/products/1744/17447336_sb.jpg"]}," ",{"name":"alternateViewsImage","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"angleImage","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"backViewImage","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"energyGuideImage","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"leftViewImage","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"accessoriesImage","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"remoteControlImage","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"rightViewImage","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"topViewImage","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"albumTitle","attributes":{},"isSelfClosing":false,"children":["Invitation to Forever"]}," ",{"name":"artistName","attributes":{},"isSelfClosing":false,"children":["Takara"]}," ",{"name":"artistId","attributes":{},"isSelfClosing":false,"children":["BYPart66281"]}," ",{"name":"originalReleaseDate","attributes":{},"isSelfClosing":false,"children":["2008-07-01"]}," ",{"name":"parentalAdvisory","attributes":{},"isSelfClosing":false,"children":["false"]}," ",{"name":"mediaCount","attributes":{},"isSelfClosing":false,"children":["1"]}," ",{"name":"monoStereo","attributes":{},"isSelfClosing":false,"children":["Stereo"]}," ",{"name":"studioLive","attributes":{},"isSelfClosing":false,"children":["Studio"]}," ",{"name":"inStorePickup","attributes":{},"isSelfClosing":false,"children":["false"]}," ",{"name":"friendsAndFamilyPickup","attributes":{},"isSelfClosing":false,"children":["false"]}," ",{"name":"homeDelivery","attributes":{},"isSelfClosing":false,"children":["false"]}," ",{"name":"quantityLimit","attributes":{},"isSelfClosing":false,"children":["3"]}," ",{"name":"fulfilledBy","attributes":{},"isSelfClosing":false,"children":["BestBuy.com"]}," ",{"name":"relatedNapsterSkus","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"relatedBestBuySkus","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"bundledIn","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"albumLabel","attributes":{},"isSelfClosing":false,"children":["Prog Rock Records"]}," ",{"name":"genre","attributes":{},"isSelfClosing":false,"children":["Hard Rock"]}," ",{"name":"dollarSavings","attributes":{},"isSelfClosing":false,"children":["0.00"]}," ",{"name":"percentSavings","attributes":{},"isSelfClosing":false,"children":["0.0"]}," ",{"name":"orderable","attributes":{},"isSelfClosing":false,"children":["Available"]}," ",{"name":"shippingWeight","attributes":{},"isSelfClosing":false,"children":["0.25"]}," ",{"name":"offers","attributes":{},"isSelfClosing":false,"children":[" ",{"name":"offer","attributes":{},"isSelfClosing":false,"children":[" ",{"name":"id","attributes":{},"isSelfClosing":false,"children":["148313"]}," ",{"name":"heading","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"text","attributes":{},"isSelfClosing":false,"children":["Free Shipping on Orders $35 and Up"]}," ",{"name":"url","attributes":{},"isSelfClosing":false,"children":["/site/offer/148313/pcmcat748301485567.c?id=pcmcat748301485567"]}," ",{"name":"imageUrl","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"type","attributes":{},"isSelfClosing":false,"children":["special_offer"]}," ",{"name":"startDate","attributes":{},"isSelfClosing":false,"children":["2016-01-02 23:45:00 -0600"]}," ",{"name":"endDate","attributes":{},"isSelfClosing":false,"children":["2018-03-31 23:59:59 -0500"]}," "]}," "]}," ",{"name":"marketplace","attributes":{},"isSelfClosing":false,"children":["false"]}," ",{"name":"listingId","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"sellerId","attributes":{},"isSelfClosing":true,"children":[]}," ",{"name":"shippingRestrictions","attributes":{},"isSelfClosing":true,"children":[]}," "]}'
data = JSON.parse(data);
//offending line of code******
part1 = jsonQuery('children.[name=categoryPath].children[*name=category].children', {data: data}).value
console.log(part1)
//which will return the following:
/*[ [ ' ',
{ name: 'id',
attributes: {},
isSelfClosing: false,
children: [Object] },
' ',
{ name: 'name',
attributes: {},
isSelfClosing: false,
children: [Object] },
' ' ],
[ ' ',
{ name: 'id',
attributes: {},
isSelfClosing: false,
children: [Object] },
' ',
{ name: 'name',
attributes: {},
isSelfClosing: false,
children: [Object] },
' ' ],
[ ' ',
{ name: 'id',
attributes: {},
isSelfClosing: false,
children: [Object] },
' ',
{ name: 'name',
attributes: {},
isSelfClosing: false,
children: [Object] },
' ' ],
[ ' ',
{ name: 'id',
attributes: {},
isSelfClosing: false,
children: [Object] },
' ',
{ name: 'name',
attributes: {},
isSelfClosing: false,
children: [Object] },
' ' ],
[ ' ',
{ name: 'id',
attributes: {},
isSelfClosing: false,
children: [Object] },
' ',
{ name: 'name',
attributes: {},
isSelfClosing: false,
children: [Object] },
' ' ] ]
*/
/*if you run the above snippet you will get a result but I can't seem to drill down any further than that. I am trying to access the multiple 'children' objects but the [*xxxxx=xxxxx] feature doesn't seem to be working with an array or arrays.*/
Thanks in advance.
The text was updated successfully, but these errors were encountered:
hi,
I am trying to use the multiple matching items qry but experiencing an issue at a certain level in the json hierarchy. It seems to be related to an array or arrays opposed to an array of objects as follows (sorry for the annoyingly long snippet of json but I want to make this as easy as possible to debug).
Thanks in advance.
The text was updated successfully, but these errors were encountered: