在Java中使用JSON创建对象
使用API,我需要一个包含大量不同数据的选项链。看起来是这样的:
```
[
putCall=PUT
symbol=AAPL_012023P100
description=AAPL Jan 20 2023 100 Put
exchangeName=OPR
bidPrice=10.05
askPrice=10.3
lastPrice=10.15
bidAskSize=78X102
markPrice=10.18
bidSize=78
askSize=102
lastSize=0
highPrice=10.15
lowPrice=9.85
openPrice=0.0
closePrice=9.98
totalVolume=334
quoteTimeInLong=1612904400035
tradeTimeInLong=1612903831902
netChange=0.17
volatility=37.645
delta=-0.195
gamma=0.004
theta=-0.014
vega=0.524
rho=-0.676
timeValue=10.15
openInterest=7941
isInTheMoney=false
theoreticalOptionValue=10.175
theoreticalVolatility=29.0
isMini=false
isNonStandard=false
optionDeliverablesList=<null>
strikePrice=100.0
expirationDate=1674248400000
expirationType=R
multiplier=100.0
settlementType=
deliverableNote=
isIndexOption=<null>
percentChange=1.75
markChange=0.2
markPercentChange=2.01
otherFields={lastTradingDay=1674262800000, daysToExpiration=709, tradeDate=null}
]], ```
这是它返回的众多产品中的一部分。我需要所有的。因此,使用Jackson,我理解如何使用以下内容将其转换为JSON:
```
ObjectMapper mapper = new ObjectMapper();
String data = eq.toString();
mapper.writerWithDefaultPrettyPrinter().writeValueAsString(data);
现在,这清理了一些,但现在我真正需要的。。我需要三样东西。我想用以下字段为每一项创建一个对象:openInterest、totalVolume和description
我尝试过搜索这个,但当你有多个值时,我无法找到它。我在上面发布的只是API返回给我的众多条目之一。我真的很感谢你的帮助:)
共 (0) 个答案