Commit Graph

20 Commits

Author SHA1 Message Date
HUMORCE
63b858c41f style: Use correct casing for $PSScriptRoot (#4775) 2022-03-04 22:55:45 +08:00
Rashil Gandhi
cbe29eddb3 chore: Update repo links 2021-12-16 01:09:21 +05:30
Pratik Chowdhury
4ec9eccdb4 feat(checkver): improve JSONPath extraction support (#4522) 2021-11-29 16:55:13 +08:00
Hsiao-nan Cheung
03ebcc2984 supporting: Update Newtonsoft.Json to 11.0.2, Newtonsoft.Json.Schema to 3.0.10 (#3043)
- Update supporting\validator\bin\Newtonsoft.Json to 11.0.2
  - **HIGHLIGHT**: support for regex operator in JSON Paths
  - Latest Newtonsoft.Json version is 12.0.1, which has some compatibility issues with Json.Schema 3.0.10 and PowerShell Core 6.1.12 (On my PC)
- Update supporting\validator\bin\Newtonsoft.Json.Schema to 3.0.10
- Use .NET 4.5 instead of .NET 4.0, since Scoop's requirements is [.NET Framework 4.5+](https://github.com/lukesampson/scoop#requirements)
- Modify `json_path()` to escape `$version` substitutions when `$jsonpath` has regex

**EXAMPLE OF JPATH REGEX**
```json
"checkver": {
    "url": "https://dist.nuget.org/index.json",
    "jp": "$..versions[?(@.displayName =~ /.*recommended.*/)].version"
}
```
2019-02-16 22:20:37 +01:00
Hsiao-nan Cheung
034103fb0e Add JArray::Parse() to json_path in lib/json.ps1 (#3011)
Some JSON file ([example](https://mranapi.azurewebsites.net/api/download)) is surrounded by brackets ("[", "]") and cannot be parsed using `[Newtonsoft.Json.Linq.JObject]::Parse()` in `json_path()`. Instead, they could be parsed by `[Newtonsoft.Json.Linq.JArray]::Parse()` and then be treated as normal, e.g., applies a filter (script) expression.

- Add `[Newtonsoft.Json.Linq.JArray]::Parse()` after `[Newtonsoft.Json.Linq.JObject]::Parse()` failed
- Some JArray are handled by `json_path_legacy()` when `json_path()` throw error before, and the JSONPath is illegal when parsed with `JArray::Parse()`. To keep compatibility, add try-catch in this situation and let `json_path_legacy()` handle them still.
- In the above situation, manifest maintainer should use double dots after `$`, i.e., use `$..NODE` instead of `$.NODE` since it is a JArray contained the JObject.
2019-01-20 12:52:57 +01:00
Hsiao-nan Cheung
dfe846aca0 Add version variables to JSONPath 2019-01-17 16:14:10 +08:00
Jakub Čábera
87df537f8c [json] Apparently I cannot use variable (#2768)
json.ps1: Fix a variable Problem introduced with the last changes
2018-11-14 05:41:04 +01:00
Jakub Čábera
3e1649553d formatjson.ps1: Format single value Arrays into String (#2642)
- Automatically convert single value arrays and recursively normalize PSObjects values
- Add tests
- Add .yml .editorconfig settings
2018-11-13 20:49:20 +01:00
Richard Kuhnt
fb58e92c13 json: catch JsonReaderException 2018-09-14 18:32:31 +02:00
Brandon Smith
f011f249e1 Normalize multi-line strings to string arrays on format (#2444) 2018-07-29 13:24:28 +02:00
Philippe Crama
463b7ef663 Adapt to path change of Newtonsoft.Json.dll from #2024 (see f0a15886) (#2034) 2018-02-21 11:46:03 +01:00
Richard Kuhnt
12c8248439 Move Add-Type into json_path (possible fix for #1702) 2017-09-11 21:29:14 +02:00
Richard Kuhnt
82ec0fe7a1 Use Newtonsoft.Json for JSONPath querys 2017-09-10 18:04:03 +02:00
Richard Kuhnt
45721fc54c Add support arrays without a property name to json path (e.g. $.[0]) 2017-05-08 13:00:05 +02:00
Richard Kuhnt
bdfbbad513 Revert changes to json_path function for arrays 2017-04-15 18:32:45 +02:00
Richard Kuhnt
38deec90b9 Fix $basename replacement in json_path function 2017-04-15 14:06:01 +02:00
Richard Kuhnt
3050a44244 Fix hash detection and improve json path for arrays 2017-04-15 13:58:55 +02:00
Richard Kuhnt
825f19aa52 Add jsonpath support for checkver and hash extraction
Unravel if-blocks in checkver

Use new jsonpath for openssl, nuget, dart and bfg
2017-03-03 21:15:37 +01:00
Rémy
b347148bbb json depth 2016-12-11 11:24:37 +01:00
Rémy
904d0703f9 custom json formatter 2016-12-11 09:50:09 +01:00