jsonquery icon indicating copy to clipboard operation
jsonquery copied to clipboard

field starts with @

Open fkarakas opened this issue 2 years ago • 2 comments

Hello, Evaluating your lib, i noticed that when the field name contains un @ it seems not to work properly (json-ld file)

nodes := jsonquery.QuerySelectorAll(doc, xpath.MustCompile("//*[@type='TVEpisode']"))

Regards

fkarakas avatar Oct 25 '23 16:10 fkarakas

you are means JSON like this {"@type": "123"}, right? not test yet.

zhengchun avatar Oct 26 '23 05:10 zhengchun

yes json like

{
  "@context": "http://schema.org",
  "@type": "DataFeed",
  "dateModified": "2023-10-25T12:05:01Z",
  "dataFeedElement": [
    {
      "@context": [
        "http://schema.org",
        {
          "@language": "fr"
        }
      ],
      "@type": "TVEpisode",
      "@id": "https://tv.com",
      "url": "https://tv.com/video1",
      "name": "video 1",
      "image": {
        "@context": "http://schema.org",
        "@type": "ImageObject",
        "contentUrl": "https://tv.com/video1",
        "additionalProperty": [
          {
            "@type": "PropertyValue",
            "name": "contentAttributes",
            "value": [
              "iconic",
              "poster",
              "smallFormat",
              "largeFormat"
            ]
          }
        ]
      },
      "episodeNumber": 10000,
      "partOfSeason": {
        "@type": "TVSeason",
        "@id": "https://tv.com/season1",
        "url": "https://tv.com/season1",
        "seasonNumber": 1
      },
      "partOfSeries": {
        "@type": "TVSeries",
        "@id": "https://tv.com/series1",
        "url": "https://tv.com/series1",
        "name": "Quotidien"
      },
      "potentialAction": [
        {
          "@type": "WatchAction",
          "target": {
            "@type": "EntryPoint",
            "urlTemplate": "https://tv.com/series1",
            "inLanguage": "fr",
            "actionPlatform": [
              "http://schema.org/AndroidPlatform",
              "http://schema.org/DesktopWebPlatform",
              "http://schema.org/IOSPlatform",
              "http://schema.org/MobileWebPlatform"
            ]
          },
          "actionAccessibilityRequirement": {
            "@type": "ActionAccessSpecification",
            "category": "free",
            "availabilityStarts": "2017-01-16T18:40:00Z",
            "availabilityEnds": "2029-12-31T20:00:00Z",
            "eligibleRegion": [
              {
                "@type": "Country",
                "name": "US"
              }
            ]
          }
        },
        {
          "@type": "WatchAction",
          "target": {
            "@type": "EntryPoint",
            "urlTemplate": "https://tv.com/video1",
            "inLanguage": "fr",
            "actionPlatform": [
              "http://schema.org/AndroidTVPlatform"
            ]
          },
          "actionAccessibilityRequirement": {
            "@type": "ActionAccessSpecification",
            "category": "free",
            "availabilityStarts": "2017-01-16T18:40:00Z",
            "availabilityEnds": "2029-12-31T20:00:00Z",
            "eligibleRegion": [
              {
                "@type": "Country",
                "name": "FR"
              }
            ]
          }
        }
      ]
    }
  ]
}

The following query returns 1 result

nodes := jsonquery.QuerySelectorAll(doc, xpath.MustCompile("//*[name='video 1']"))

But this other query returns no result

nodes := jsonquery.QuerySelectorAll(doc, xpath.MustCompile("//*[@type='TVEpisode']"))

fkarakas avatar Oct 26 '23 10:10 fkarakas