ScoopInstaller / Scoop

A command-line installer for Windows.

Home Page:https://scoop.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] `json_path` returning string literal `\n` when using union operator

ryansuhartanto opened this issue · comments

Bug Report

Current Behavior

Currently, json_path would return the string literal \n when using union operator ([,]).

Expected Behavior

Instead, json_path should return the values with new lines, separated by commas, and contained in brackets ([]).

Additional context/output

Taken from ScoopInstaller/Java#515 (comment).

I am trying to extract the version and UUID from this JSON https://api.azul.com/metadata/v1/zulu/packages?java_version=17&os=windows&arch=x86&archive_type=zip&java_package_type=jdk&javafx_bundled=false&crac_supported=false&latest=true&page_size=2.

Using this JSON path should returns 4 different values

$..['distro_version','package_uuid']

Note that https://jsonpath.com/ only accept this syntax

$..distro_version,package_uuid

Currently, the returned value is

[
  17,
  48,
  15,
  0
]\ncef00b50-77db-400a-afdd-b9e391e44631\n[
  17,
  48,
  15,
  0
]\n25351721-5e7e-4eef-a0ef-0c3686b38631

However, I don't think this is a feature and trying to the match regex for it would break if this is changed/fixed.

System details

  • Windows version: 11
  • OS architecture: 64bit
  • PowerShell version: 7.4.2

Good catch! It should return serialized result rather than a concatenated result.