Skip to content

Commit a75ad76

Browse files
lazarusAomus
andauthored
Update to JSON v1 (#741)
* bump JSON, and lets see * do * Object body into Dict * rm README comment * Set project version to v1.97.1 * JSON no longer exports `json` * Explicitly import JSON.jl bindings --------- Co-authored-by: Curtis Vogt <[email protected]>
1 parent 17471b8 commit a75ad76

File tree

9 files changed

+14
-15
lines changed

9 files changed

+14
-15
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Compat = "4.11"
2929
GitHub = "5"
3030
HTTP = "1"
3131
IniFile = "0.5"
32-
JSON = "0.18, 0.19, 0.20, 0.21"
32+
JSON = "0.18, 0.19, 0.20, 0.21, 1"
3333
MbedTLS = "0.6, 0.7, 1"
3434
Mocking = "0.7, 0.8"
3535
OrderedCollections = "1.3"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,4 @@ As well as some hand-written packages for specific AWS services:
203203
* [AWSEC2.jl](https://github.com/samoconnor/AWSEC2.jl) - Julia 0.6
204204
* [AWSLambda.jl](https://github.com/samoconnor/AWSLambda.jl) - Julia 0.6
205205
* [AWSSES.jl](https://github.com/samoconnor/AWSSES.jl) - Julia 0.6
206-
* [AWSSDB.jl](https://github.com/samoconnor/AWSSDB.jl) - Julia 0.6
206+
* [AWSSDB.jl](https://github.com/samoconnor/AWSSDB.jl) - Julia 0.6

src/AWS.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ using Base64
55
using Dates
66
using Downloads: Downloads, Downloader, Curl
77
using HTTP
8+
using JSON: JSON
89
using MbedTLS
910
using Mocking
1011
using OrderedCollections: LittleDict, OrderedDict
@@ -401,7 +402,7 @@ function (service::JSONService)(
401402
use_response_type=feature_set.use_response_type,
402403
resource=POST_RESOURCE,
403404
request_method="POST",
404-
content=json(args),
405+
content=JSON.json(args),
405406
url=generate_service_url(aws_config, service.endpoint_prefix, POST_RESOURCE),
406407
)
407408

@@ -458,7 +459,7 @@ function (service::RestJSONService)(
458459
end
459460

460461
request.headers["Content-Type"] = "application/json"
461-
request.content = json(args)
462+
request.content = JSON.json(args)
462463

463464
return submit_request(aws_config, request; return_headers=return_headers)
464465
end

src/AWSCredentials.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Dates
22
using HTTP
33
using IniFile
4-
using JSON
54
using Mocking
65

76
using ..AWSExceptions
@@ -232,12 +231,12 @@ function ec2_instance_credentials(profile::AbstractString)
232231

233232
info = IMDS.get("/latest/meta-data/iam/info")
234233
info === nothing && return nothing
235-
info = JSON.parse(info)
234+
info = JSON.parse(info; dicttype=Dict)
236235

237236
# Get credentials for the role associated to the instance via instance profile.
238237
name = IMDS.get("/latest/meta-data/iam/security-credentials/")
239238
creds = IMDS.get("/latest/meta-data/iam/security-credentials/$name")
240-
parsed = JSON.parse(creds)
239+
parsed = JSON.parse(creds; dicttype=Dict)
241240
instance_profile_creds = AWSCredentials(
242241
parsed["AccessKeyId"],
243242
parsed["SecretAccessKey"],
@@ -332,7 +331,7 @@ function ecs_instance_credentials()
332331
rethrow()
333332
end
334333
new_creds = String(response.body)
335-
new_creds = JSON.parse(new_creds)
334+
new_creds = JSON.parse(new_creds; dicttype=Dict)
336335

337336
expiry = DateTime(rstrip(new_creds["Expiration"], 'Z'))
338337

src/AWSExceptions.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module AWSExceptions
22

33
using HTTP
4-
using JSON
4+
using JSON: JSON
55
using XMLDict
66
using XMLDict: XMLDictElement
77

@@ -87,12 +87,12 @@ function AWSException(e::HTTP.StatusError, body::AbstractString)
8787
if !isempty(body)
8888
# Extract API error code from Lambda-style JSON error message...
8989
if endswith(content_type, "json")
90-
info = JSON.parse(body)
90+
info = JSON.parse(body; dicttype=Dict)
9191
end
9292

9393
# Extract API error code from JSON error message...
9494
if occursin(r"^application/x-amz-json-1\.[01]$", content_type)
95-
info = JSON.parse(body)
95+
info = JSON.parse(body; dicttype=Dict)
9696
if haskey(info, "__type")
9797
code = rsplit(info["__type"], '#'; limit=2)[end]
9898
end

src/AWSMetadata.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using Base64
44
using ..AWSExceptions
55
using GitHub
66
using HTTP
7-
using JSON
7+
using JSON: JSON
88
using Mocking
99
using OrderedCollections: LittleDict, OrderedDict
1010

test/patch.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ using AWS
44
using Dates
55
using Downloads: Downloads
66
using HTTP
7-
using JSON
87
using GitHub
98
using Mocking
109
using OrderedCollections: LittleDict

test/resource/setup.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
using AWS
66
using AWS: AWSException
7-
using JSON
7+
using JSON: JSON
88

99
@service CloudFormation use_response_type = true
1010
@service IAM use_response_type = true

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ using Downloads
2424
using GitHub
2525
using HTTP
2626
using IniFile: Inifile, sections
27-
using JSON
27+
using JSON: JSON
2828
using OrderedCollections: LittleDict, OrderedDict
2929
using MbedTLS: digest, MD_SHA256, MD_MD5
3030
using Mocking

0 commit comments

Comments
 (0)