Amazon API 返回奇怪的尺寸。在网站上,他们显示:
Product Dimensions: 8.7 x 7.9 x 0.6 inches ; 1.8 ounces
Shipping Weight: 4 ounces
当 API 返回时:
[ItemDimensions] => Array
(
[Height] => 59
[Length] => 866
[Weight] => 11
[Width] => 787
)
[PackageDimensions] => Array
(
[Height] => 50
[Length] => 700
[Weight] => 25
[Width] => 200
)
我不确定那是什么单位。我确认了两次以确保它是同一产品。
我需要将其转换为 mm
和 grams
。 22cm 或 220mm 是 8.7 英寸
所以不知道返回的是 50
还是 59
。重量也一样。
最佳答案
产品尺寸以英寸为单位。它们的显示是通过将存储的值除以100并调整句点后的第一个位置来实现的。
Length -> stored as 866 - displayed as 8.7
Width -> stored as 787 - displayed as 7.9
Height -> stored as 59 - displayed as 0.6
您可以通过转换将其转换为公制。 1 英寸 = 2.54 厘米。
取长
866 / 100 = 8.66
8.66 * 2.54 = 21.9962 centimetres.
Display as 22 cm, or 21.99 cm, etc...
重量以磅为单位存储,但以盎司显示。 1 磅 = 16 盎司,或 0.11 磅 = 1.76 盎司。 1.76调整为1.8。
因为 1 磅 = 453.592 克,你可以通过做转移
0.11 * 453.492 = 49.89512 grams.
Display as 49 g, or 49.9 g, etc...
关于api - 单位换算 - Amazon API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28712921/