- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有 Json
字符串:
[{"cid":"1039420885783365","name":"","s":"TSLA160916C00005000","e":"OPRA","p":"219.64","cs":"chb","c":"0.00","cp":"0.00","b":"190.30","a":"194.85","oi":"2","vol":"-","strike":"5.00","expiry":"Sep 16, 2016"}, ... ]
我的代码:
case class OptionEntry(cid: String,
name: String,
s: String,
e: String,
p: String,
cs: String,
c: String,
cp: String,
b: String,
a: String,
oi: String,
vol: String,
strike: String,
expiry: String)
val optionEntries = Json.parse(jsonString)
implicit val optionEntryReads: Reads[OptionEntry] = (
(JsPath \ "cid").read[String] and
(JsPath \ "name").read[String] and
(JsPath \ "s").read[String] and
(JsPath \ "e").read[String] and
(JsPath \ "p").read[String] and
(JsPath \ "cs").read[String] and
(JsPath \ "c").read[String] and
(JsPath \ "cp").read[String] and
(JsPath \ "b").read[String] and
(JsPath \ "a").read[String] and
(JsPath \ "oi").read[String] and
(JsPath \ "vol").read[String] and
(JsPath \ "strike").read[String] and
(JsPath \ "expiry").read[String]
)(OptionEntry.apply _)
println(optionEntries.validate[List[OptionEntry]])
Json 字符串:
[{"cid":"1039420885783365","name":"","s":"TSLA160916C00005000","e":"OPRA","p":"219.64","cs":"chb","c":"0.00","cp":"0.00","b":"194.70","a":"197.90","oi":"2","vol":"-","strike":"5.00","expiry":"Sep 16, 2016"},{"cid":"259816193292639","name":"","s":"TSLA160916C00010000","e":"OPRA","p":"182.50","cs":"chb","c":"0.00","cp":"0.00","b":"189.85","a":"192.75","oi":"0","vol":"-","strike":"10.00","expiry":"Sep 16, 2016"},{"cid":"834521657091252","name":"","s":"TSLA160916C00015000","e":"OPRA","p":"211.09","cs":"chb","c":"0.00","cp":"0.00","b":"184.80","a":"187.20","oi":"1","vol":"-","strike":"15.00","expiry":"Sep 16, 2016"},{"cid":"58038573817889","name":"","s":"TSLA160916C00020000","e":"OPRA","p":"206.06","cs":"chb","c":"0.00","cp":"0.00","b":"179.70","a":"182.20","oi":"1","vol":"-","strike":"20.00","expiry":"Sep 16, 2016"},{"cid":"400783271986149","name":"","s":"TSLA160916C00025000","e":"OPRA","p":"151.58","cs":"chb","c":"0.00","cp":"0.00","b":"174.85","a":"177.70","oi":"0","vol":"-","strike":"25.00","expiry":"Sep 16, 2016"},{"cid":"397108163551042","name":"","s":"TSLA160916C00030000","e":"OPRA","p":"-","c":"-","b":"169.85","a":"172.70","oi":"0","vol":"-","strike":"30.00","expiry":"Sep 16, 2016"},{"cid":"39807976369121","name":"","s":"TSLA160916C00035000","e":"OPRA","p":"-","c":"-","b":"164.70","a":"167.70","oi":"0","vol":"-","strike":"35.00","expiry":"Sep 16, 2016"},{"cid":"162843593973912","name":"","s":"TSLA160916C00040000","e":"OPRA","p":"186.17","cs":"chb","c":"0.00","cp":"0.00","b":"159.85","a":"162.25","oi":"1","vol":"-","strike":"40.00","expiry":"Sep 16, 2016"},{"cid":"105072414761672","name":"","s":"TSLA160916C00045000","e":"OPRA","p":"208.10","cs":"chb","c":"0.00","cp":"0.00","b":"154.85","a":"157.75","oi":"1","vol":"-","strike":"45.00","expiry":"Sep 16, 2016"},{"cid":"839642082077864","name":"","s":"TSLA160916C00050000","e":"OPRA","p":"158.00","cs":"chb","c":"0.00","cp":"0.00","b":"149.85","a":"152.90","oi":"0","vol":"-","strike":"50.00","expiry":"Sep 16, 2016"},{"cid":"738268109616581","name":"","s":"TSLA160916C00055000","e":"OPRA","p":"171.43","cs":"chb","c":"0.00","cp":"0.00","b":"144.50","a":"147.40","oi":"1","vol":"-","strike":"55.00","expiry":"Sep 16, 2016"},{"cid":"1110347752052358","name":"","s":"TSLA160916C00060000","e":"OPRA","p":"-","c":"-","b":"139.50","a":"142.75","oi":"0","vol":"-","strike":"60.00","expiry":"Sep 16, 2016"},{"cid":"701783145177326","name":"","s":"TSLA160916C00065000","e":"OPRA","p":"-","c":"-","b":"134.50","a":"137.75","oi":"0","vol":"-","strike":"65.00","expiry":"Sep 16, 2016"},{"cid":"654322547204560","name":"","s":"TSLA160916C00070000","e":"OPRA","p":"149.88","cs":"chb","c":"0.00","cp":"0.00","b":"129.70","a":"132.75","oi":"0","vol":"-","strike":"70.00","expiry":"Sep 16, 2016"},{"cid":"741226138508078","name":"","s":"TSLA160916C00075000","e":"OPRA","p":"-","c":"-","b":"124.50","a":"127.75","oi":"0","vol":"-","strike":"75.00","expiry":"Sep 16, 2016"},{"cid":"972168634803798","name":"","s":"TSLA160916C00080000","e":"OPRA","p":"-","c":"-","b":"119.50","a":"122.75","oi":"0","vol":"-","strike":"80.00","expiry":"Sep 16, 2016"},{"cid":"986485863274043","name":"","s":"TSLA160916C00085000","e":"OPRA","p":"-","c":"-","b":"114.50","a":"117.85","oi":"0","vol":"-","strike":"85.00","expiry":"Sep 16, 2016"},{"cid":"1095545768550226","name":"","s":"TSLA160916C00090000","e":"OPRA","p":"138.52","cs":"chb","c":"0.00","cp":"0.00","b":"109.85","a":"112.20","oi":"0","vol":"-","strike":"90.00","expiry":"Sep 16, 2016"},{"cid":"26254300000394","name":"","s":"TSLA160916C00095000","e":"OPRA","p":"127.10","cs":"chb","c":"0.00","cp":"0.00","b":"104.70","a":"107.90","oi":"0","vol":"-","strike":"95.00","expiry":"Sep 16, 2016"},{"cid":"1118117726847457","name":"","s":"TSLA160916C00100000","e":"OPRA","p":"123.27","cs":"chb","c":"0.00","cp":"0.00","b":"99.50","a":"102.15","oi":"13","vol":"-","strike":"100.00","expiry":"Sep 16, 2016"},{"cid":"245141050010264","name":"","s":"TSLA160916C00105000","e":"OPRA","p":"95.29","cs":"chb","c":"0.00","cp":"0.00","b":"94.70","a":"97.90","oi":"0","vol":"-","strike":"105.00","expiry":"Sep 16, 2016"},{"cid":"439847478157007","name":"","s":"TSLA160916C00110000","e":"OPRA","p":"100.90","cs":"chb","c":"0.00","cp":"0.00","b":"89.50","a":"92.20","oi":"0","vol":"-","strike":"110.00","expiry":"Sep 16, 2016"},{"cid":"41101379521672","name":"","s":"TSLA160916C00115000","e":"OPRA","p":"114.53","cs":"chb","c":"0.00","cp":"0.00","b":"84.70","a":"87.20","oi":"0","vol":"-","strike":"115.00","expiry":"Sep 16, 2016"},{"cid":"140943872831911","name":"","s":"TSLA160916C00120000","e":"OPRA","p":"105.36","cs":"chb","c":"0.00","cp":"0.00","b":"79.70","a":"82.90","oi":"0","vol":"-","strike":"120.00","expiry":"Sep 16, 2016"},{"cid":"966450180416270","name":"","s":"TSLA160916C00125000","e":"OPRA","p":"108.00","cs":"chb","c":"0.00","cp":"0.00","b":"74.85","a":"77.20","oi":"0","vol":"-","strike":"125.00","expiry":"Sep 16, 2016"},{"cid":"244268213784819","name":"","s":"TSLA160916C00130000","e":"OPRA","p":"93.40","cs":"chb","c":"0.00","cp":"0.00","b":"69.85","a":"72.30","oi":"11","vol":"-","strike":"130.00","expiry":"Sep 16, 2016"},{"cid":"439803738360712","name":"","s":"TSLA160916C00135000","e":"OPRA","p":"82.23","cs":"chb","c":"0.00","cp":"0.00","b":"64.70","a":"67.80","oi":"1","vol":"-","strike":"135.00","expiry":"Sep 16, 2016"},{"cid":"338143164805850","name":"","s":"TSLA160916C00140000","e":"OPRA","p":"88.79","cs":"chb","c":"0.00","cp":"0.00","b":"59.85","a":"62.85","oi":"1","vol":"-","strike":"140.00","expiry":"Sep 16, 2016"},{"cid":"384979845128979","name":"","s":"TSLA160916C00145000","e":"OPRA","p":"66.55","cs":"chb","c":"0.00","cp":"0.00","b":"54.85","a":"57.20","oi":"4","vol":"-","strike":"145.00","expiry":"Sep 16, 2016"},{"cid":"704065395489746","name":"","s":"TSLA160916C00150000","e":"OPRA","p":"60.00","cs":"chb","c":"0.00","cp":"0.00","b":"49.45","a":"52.20","oi":"21","vol":"-","strike":"150.00","expiry":"Sep 16, 2016"},{"cid":"942910344574849","name":"","s":"TSLA160916C00155000","e":"OPRA","p":"56.00","cs":"chb","c":"0.00","cp":"0.00","b":"44.50","a":"47.20","oi":"28","vol":"-","strike":"155.00","expiry":"Sep 16, 2016"},{"cid":"751610325900763","name":"","s":"TSLA160916C00160000","e":"OPRA","p":"42.00","cs":"chr","c":"-8.50","cp":"-16.83","b":"40.75","a":"41.30","oi":"8","vol":"10","strike":"160.00","expiry":"Sep 16, 2016"},{"cid":"580000290226652","name":"","s":"TSLA160916C00165000","e":"OPRA","p":"45.85","cs":"chb","c":"0.00","cp":"0.00","b":"34.80","a":"38.10","oi":"9","vol":"-","strike":"165.00","expiry":"Sep 16, 2016"},{"cid":"446084522487295","name":"","s":"TSLA160916C00170000","e":"OPRA","p":"27.00","cs":"chb","c":"0.00","cp":"0.00","b":"30.05","a":"32.10","oi":"12","vol":"-","strike":"170.00","expiry":"Sep 16, 2016"},{"cid":"367689129200491","name":"","s":"TSLA160916C00175000","e":"OPRA","p":"36.20","cs":"chb","c":"0.00","cp":"0.00","b":"25.15","a":"27.25","oi":"52","vol":"-","strike":"175.00","expiry":"Sep 16, 2016"},{"cid":"129646035642327","name":"","s":"TSLA160916C00180000","e":"OPRA","p":"17.20","cs":"chb","c":"0.00","cp":"0.00","b":"20.85","a":"22.05","oi":"91","vol":"-","strike":"180.00","expiry":"Sep 16, 2016"},{"cid":"733865215077307","name":"","s":"TSLA160916C00185000","e":"OPRA","p":"16.00","cs":"chg","c":"+2.50","cp":"18.52","b":"16.45","a":"17.40","oi":"34","vol":"33","strike":"185.00","expiry":"Sep 16, 2016"},{"cid":"568231138866100","name":"","s":"TSLA160916C00190000","e":"OPRA","p":"13.50","cs":"chg","c":"+3.45","cp":"34.33","b":"12.20","a":"12.65","oi":"855","vol":"8","strike":"190.00","expiry":"Sep 16, 2016"},{"cid":"427189940524630","name":"","s":"TSLA160916C00195000","e":"OPRA","p":"8.40","cs":"chg","c":"+1.75","cp":"26.32","b":"8.50","a":"8.85","oi":"1102","vol":"21","strike":"195.00","expiry":"Sep 16, 2016"},{"cid":"1082141592051119","name":"","s":"TSLA160916C00200000","e":"OPRA","p":"5.55","cs":"chg","c":"+1.40","cp":"33.73","b":"5.40","a":"5.65","oi":"1990","vol":"364","strike":"200.00","expiry":"Sep 16, 2016"},{"cid":"230121558689237","name":"","s":"TSLA160916C00205000","e":"OPRA","p":"3.47","cs":"chg","c":"+1.12","cp":"47.66","b":"3.15","a":"3.35","oi":"1324","vol":"455","strike":"205.00","expiry":"Sep 16, 2016"},{"cid":"894705236612609","name":"","s":"TSLA160916C00210000","e":"OPRA","p":"1.94","cs":"chg","c":"+0.65","cp":"50.39","b":"1.72","a":"1.80","oi":"3867","vol":"681","strike":"210.00","expiry":"Sep 16, 2016"},{"cid":"40801284708400","name":"","s":"TSLA160916C00215000","e":"OPRA","p":"0.94","cs":"chg","c":"+0.23","cp":"32.39","b":"0.90","a":"0.96","oi":"2711","vol":"375","strike":"215.00","expiry":"Sep 16, 2016"},{"cid":"529249705826744","name":"","s":"TSLA160916C00220000","e":"OPRA","p":"0.49","cs":"chg","c":"+0.10","cp":"25.64","b":"0.47","a":"0.52","oi":"4705","vol":"173","strike":"220.00","expiry":"Sep 16, 2016"},{"cid":"579788906485048","name":"","s":"TSLA160916C00225000","e":"OPRA","p":"0.31","cs":"chg","c":"+0.06","cp":"24.00","b":"0.26","a":"0.31","oi":"3102","vol":"105","strike":"225.00","expiry":"Sep 16, 2016"},{"cid":"695785114703989","name":"","s":"TSLA160916C00230000","e":"OPRA","p":"0.18","cs":"chg","c":"+0.02","cp":"12.50","b":"0.15","a":"0.21","oi":"4291","vol":"142","strike":"230.00","expiry":"Sep 16, 2016"},{"cid":"294592085765220","name":"","s":"TSLA160916C00235000","e":"OPRA","p":"0.13","cs":"chg","c":"+0.04","cp":"44.44","b":"0.09","a":"0.15","oi":"2715","vol":"40","strike":"235.00","expiry":"Sep 16, 2016"},{"cid":"614241625252","name":"","s":"TSLA160916C00240000","e":"OPRA","p":"0.05","cs":"chr","c":"-0.06","cp":"-54.55","b":"0.05","a":"0.12","oi":"4062","vol":"11","strike":"240.00","expiry":"Sep 16, 2016"},{"cid":"35412973124711","name":"","s":"TSLA160916C00245000","e":"OPRA","p":"0.15","cs":"chg","c":"+0.09","cp":"150.00","b":"0.05","a":"0.15","oi":"1359","vol":"8","strike":"245.00","expiry":"Sep 16, 2016"},{"cid":"523084247103734","name":"","s":"TSLA160916C00250000","e":"OPRA","p":"0.05","cs":"chg","c":"+0.02","cp":"66.67","b":"0.05","a":"0.10","oi":"12156","vol":"6","strike":"250.00","expiry":"Sep 16, 2016"},{"cid":"386089758942689","name":"","s":"TSLA160916C00255000","e":"OPRA","p":"0.14","cs":"chg","c":"+0.10","cp":"250.00","b":"0.01","a":"0.14","oi":"4097","vol":"1","strike":"255.00","expiry":"Sep 16, 2016"},{"cid":"342874639110958","name":"","s":"TSLA160916C00260000","e":"OPRA","p":"0.05","cs":"chg","c":"+0.02","cp":"66.67","b":"0.01","a":"0.06","oi":"5511","vol":"13","strike":"260.00","expiry":"Sep 16, 2016"},{"cid":"951449640597665","name":"","s":"TSLA160916C00265000","e":"OPRA","p":"0.03","cs":"chr","c":"-0.06","cp":"-66.67","b":"0.01","a":"0.04","oi":"693","vol":"4","strike":"265.00","expiry":"Sep 16, 2016"},{"cid":"109380551285141","name":"","s":"TSLA160916C00270000","e":"OPRA","p":"0.01","cs":"chr","c":"-0.04","cp":"-80.00","b":"-","a":"0.03","oi":"1893","vol":"10","strike":"270.00","expiry":"Sep 16, 2016"},{"cid":"663774558210813","name":"","s":"TSLA160916C00275000","e":"OPRA","p":"0.05","cs":"chb","c":"0.00","cp":"0.00","b":"0.01","a":"0.03","oi":"1124","vol":"-","strike":"275.00","expiry":"Sep 16, 2016"},{"cid":"112668851965328","name":"","s":"TSLA160916C00280000","e":"OPRA","p":"0.02","cs":"chb","c":"0.00","cp":"0.00","b":"0.01","a":"0.03","oi":"9380","vol":"-","strike":"280.00","expiry":"Sep 16, 2016"},{"cid":"23495629926976","name":"","s":"TSLA160916C00285000","e":"OPRA","p":"0.04","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"616","vol":"-","strike":"285.00","expiry":"Sep 16, 2016"},{"cid":"1004365825285358","name":"","s":"TSLA160916C00290000","e":"OPRA","p":"0.03","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.20","oi":"2332","vol":"-","strike":"290.00","expiry":"Sep 16, 2016"},{"cid":"330197077576914","name":"","s":"TSLA160916C00295000","e":"OPRA","p":"0.10","cs":"chb","c":"0.00","cp":"0.00","b":"0.01","a":"0.03","oi":"271","vol":"-","strike":"295.00","expiry":"Sep 16, 2016"},{"cid":"1015720399686345","name":"","s":"TSLA160916C00300000","e":"OPRA","p":"0.01","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"2034","vol":"2","strike":"300.00","expiry":"Sep 16, 2016"},{"cid":"371787846867782","name":"","s":"TSLA160916C00305000","e":"OPRA","p":"0.07","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.13","oi":"191","vol":"-","strike":"305.00","expiry":"Sep 16, 2016"},{"cid":"794756977768746","name":"","s":"TSLA160916C00310000","e":"OPRA","p":"0.06","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.13","oi":"341","vol":"-","strike":"310.00","expiry":"Sep 16, 2016"},{"cid":"589274365602892","name":"","s":"TSLA160916C00315000","e":"OPRA","p":"0.01","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.13","oi":"85","vol":"-","strike":"315.00","expiry":"Sep 16, 2016"},{"cid":"958135383206851","name":"","s":"TSLA160916C00320000","e":"OPRA","p":"0.02","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"449","vol":"-","strike":"320.00","expiry":"Sep 16, 2016"},{"cid":"957518746875187","name":"","s":"TSLA160916C00325000","e":"OPRA","p":"0.05","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"174","vol":"-","strike":"325.00","expiry":"Sep 16, 2016"},{"cid":"947410564957569","name":"","s":"TSLA160916C00330000","e":"OPRA","p":"0.05","cs":"chb","c":"0.00","cp":"0.00","b":"0.01","a":"0.02","oi":"254","vol":"-","strike":"330.00","expiry":"Sep 16, 2016"},{"cid":"936370081872094","name":"","s":"TSLA160916C00335000","e":"OPRA","p":"0.08","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"121","vol":"-","strike":"335.00","expiry":"Sep 16, 2016"},{"cid":"869235801270819","name":"","s":"TSLA160916C00340000","e":"OPRA","p":"0.05","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"122","vol":"-","strike":"340.00","expiry":"Sep 16, 2016"},{"cid":"784091407817438","name":"","s":"TSLA160916C00345000","e":"OPRA","p":"0.79","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"38","vol":"-","strike":"345.00","expiry":"Sep 16, 2016"},{"cid":"85239239120130","name":"","s":"TSLA160916C00350000","e":"OPRA","p":"0.05","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"454","vol":"-","strike":"350.00","expiry":"Sep 16, 2016"},{"cid":"211447090706369","name":"","s":"TSLA160916C00355000","e":"OPRA","p":"1.93","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"20","vol":"-","strike":"355.00","expiry":"Sep 16, 2016"},{"cid":"351823136572506","name":"","s":"TSLA160916C00360000","e":"OPRA","p":"0.55","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"64","vol":"-","strike":"360.00","expiry":"Sep 16, 2016"},{"cid":"804800293852884","name":"","s":"TSLA160916C00365000","e":"OPRA","p":"1.35","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"118","vol":"-","strike":"365.00","expiry":"Sep 16, 2016"},{"cid":"774749443516921","name":"","s":"TSLA160916C00370000","e":"OPRA","p":"0.23","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"23","vol":"-","strike":"370.00","expiry":"Sep 16, 2016"},{"cid":"62924785666214","name":"","s":"TSLA160916C00375000","e":"OPRA","p":"0.17","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"168","vol":"-","strike":"375.00","expiry":"Sep 16, 2016"},{"cid":"762305391919801","name":"","s":"TSLA160916C00380000","e":"OPRA","p":"0.10","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.13","oi":"89","vol":"-","strike":"380.00","expiry":"Sep 16, 2016"},{"cid":"793017123886757","name":"","s":"TSLA160916C00385000","e":"OPRA","p":"1.45","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"228","vol":"-","strike":"385.00","expiry":"Sep 16, 2016"},{"cid":"826948232988990","name":"","s":"TSLA160916C00390000","e":"OPRA","p":"0.45","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"41","vol":"-","strike":"390.00","expiry":"Sep 16, 2016"},{"cid":"598383802441737","name":"","s":"TSLA160916C00395000","e":"OPRA","p":"0.24","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"20","vol":"-","strike":"395.00","expiry":"Sep 16, 2016"},{"cid":"983900197677305","name":"","s":"TSLA160916C00400000","e":"OPRA","p":"0.02","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"278","vol":"-","strike":"400.00","expiry":"Sep 16, 2016"},{"cid":"322652828621972","name":"","s":"TSLA160916C00410000","e":"OPRA","p":"0.15","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"25","vol":"-","strike":"410.00","expiry":"Sep 16, 2016"},{"cid":"55290337064305","name":"","s":"TSLA160916C00420000","e":"OPRA","p":"0.49","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"48","vol":"-","strike":"420.00","expiry":"Sep 16, 2016"},{"cid":"406767026062965","name":"","s":"TSLA160916C00430000","e":"OPRA","p":"-","c":"-","b":"-","a":"0.03","oi":"0","vol":"-","strike":"430.00","expiry":"Sep 16, 2016"},{"cid":"806365700330173","name":"","s":"TSLA160916C00440000","e":"OPRA","p":"0.84","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"60","vol":"-","strike":"440.00","expiry":"Sep 16, 2016"},{"cid":"225372731645320","name":"","s":"TSLA160916C00450000","e":"OPRA","p":"0.06","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"41","vol":"-","strike":"450.00","expiry":"Sep 16, 2016"},{"cid":"341884545155871","name":"","s":"TSLA160916C00460000","e":"OPRA","p":"0.94","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"29","vol":"-","strike":"460.00","expiry":"Sep 16, 2016"},{"cid":"760487192324210","name":"","s":"TSLA160916C00470000","e":"OPRA","p":"0.20","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"27","vol":"-","strike":"470.00","expiry":"Sep 16, 2016"},{"cid":"211838278250894","name":"","s":"TSLA160916C00480000","e":"OPRA","p":"0.10","cs":"chb","c":"0.00","cp":"0.00","b":"-","a":"0.03","oi":"89","vol":"-","strike":"480.00","expiry":"Sep 16, 2016"}]
但是,我收到错误消息(来自 print
):
JsError(List(((5)/cp,List(ValidationError(List(error.path.missing),WrappedArray()))), ((5)/cs,List(ValidationError(List(error.path.missing),WrappedArray()))), ((6)/cp,List(ValidationError(List(error.path.missing),WrappedArray()))), ((6)/cs,List(ValidationError(List(error.path.missing),WrappedArray()))), ((11)/cp,List(ValidationError(List(error.path.missing),WrappedArray()))), ((11)/cs,List(ValidationError(List(error.path.missing),WrappedArray()))), ((12)/cp,List(ValidationError(List(error.path.missing),WrappedArray()))), ((12)/cs,List(ValidationError(List(error.path.missing),WrappedArray()))), ((14)/cp,List(ValidationError(List(error.path.missing),WrappedArray()))), ((14)/cs,List(ValidationError(List(error.path.missing),WrappedArray()))), ((15)/cp,List(ValidationError(List(error.path.missing),WrappedArray()))), ((15)/cs,List(ValidationError(List(error.path.missing),WrappedArray()))), ((16)/cp,List(ValidationError(List(error.path.missing),WrappedArray()))), ((16)/cs,List(ValidationError(List(error.path.missing),WrappedArray()))), ((82)/cp,List(ValidationError(List(error.path.missing),WrappedArray()))), ((82)/cs,List(ValidationError(List(error.path.missing),WrappedArray())))))
我错过了什么?
编辑:
显然,8/88 个实例中缺少“cp”字段。因为我只对“p”和“strike”字段感兴趣。我将问题更改为:
如何只读取这两个字段(p 和 Strike)?忽略其余部分。
最佳答案
如果您只对“p”和“strike”字段感兴趣,可以使用以下代码:
case class OptionEntry(p: String,
strike: String)
val optionEntries = Json.parse(jsonString)
implicit val optionEntryReads: Reads[OptionEntry] = (
(JsPath \ "p").read[String] and
(JsPath \ "strike").read[String]
)(OptionEntry.apply _)
println(optionEntries.validate[List[OptionEntry]])
所以您不必阅读所有字段。但是如果你想保留字段并且你知道有时会丢失“cp”字段,你可以通过以下代码将其设置为Option
:
case class OptionEntry(cid: String,
name: String,
s: String,
e: String,
p: String,
cs: String,
c: String,
cp: Option[String],
b: String,
a: String,
oi: String,
vol: String,
strike: String,
expiry: String)
val optionEntries = Json.parse(jsonString)
implicit val optionEntryReads: Reads[OptionEntry] = (
(JsPath \ "cid").read[String] and
(JsPath \ "name").read[String] and
(JsPath \ "s").read[String] and
(JsPath \ "e").read[String] and
(JsPath \ "p").read[String] and
(JsPath \ "cs").read[String] and
(JsPath \ "c").read[String] and
(JsPath \ "cp").readNullable[String] and
(JsPath \ "b").read[String] and
(JsPath \ "a").read[String] and
(JsPath \ "oi").read[String] and
(JsPath \ "vol").read[String] and
(JsPath \ "strike").read[String] and
(JsPath \ "expiry").read[String]
)(OptionEntry.apply _)
println(optionEntries.validate[List[OptionEntry]])
关于json - Play Json 中的验证错误(路径丢失),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39347050/
BufferedImage image = ImageIO.read(SpriteSheet.class.getResource(path)); BufferedImage image = Image
希望有人能够帮助我解决将我的 React 应用程序推送到 Heroku 时遇到的问题。 heroku 日志反复显示以下错误。 at=error code=H10 desc="App crashed"
我是 Kotlin 的新手,我正在经历这样的例子。 . . package com.example.lambda1 import spark.Spark.get fun main(args: Arra
如果您已经安装了 32 位 JDK,请在中定义一个 JAVA_HOME 变量 Computer>System Properties>System Setting>Enviorment VAriable
我正在开发一个独立于平台的应用程序。我收到一个文件 URL*。在 Windows 上,这些是: file:///Z:/folder%20to%20file/file.txt file://host/f
我在 OSX、Objective-C 上。 我有一个像 这样的路径/NSURL /Users/xxx/Desktop/image2.png 但我将它传递给第三方应用程序,该应用程序会像 excpect
我已经安装了 Android studio 和插件的 DART,FLUTTER 来启动 flutter,但是因为我在创建我的第一个 flutter 项目时无法提供 sdk 路径。 最佳答案 我试图找出
127.0.0.1:8000/api/仅包含来自第二个应用程序的 url,但我将两个 url 模块链接到相同的模式。甚至有可能做到这一点吗? 第一个应用程序: from django.urls imp
对于大量图像(大约 1k,加上相同数量的拇指,在大约 500 个文件夹中),我们要求网站上使用的所有图像 URI 都必须具有 SEO 优化路径。它们已经准备好并提供完整的路径结构(每个文件夹包含一个具
为什么 f 不是一个文件?什么可能导致这种情况? String currentPhotoPath = "file:/storage/sdcard0/Pictures/someFileName.
Gradle 中的项目名称或路径中允许使用哪些字符? 它是否与特定操作系统的目录名称中允许的字符相同(例如: http://en.wikipedia.org/wiki/Filename#Reserve
我有一个包含文件夹路径的表格。我需要找到层次结构中这些文件夹之间的所有“差距”。我的意思是,如果表格包含这 3 个文件夹: 'A' 'A\B\C' 'A\B\C\D\E\F\G' 我需要在层次结构中找
我在 Linux 服务器上的/home/subversion 中安装了 svn - 那里有一个 ROOT 文件夹,其中包含 db 和 conf 等文件夹。没有映射到项目名称的文件夹,请有人告诉我如何列
对于我的图像位置:/src/assets/bitmap/sample.jpg 给出了关键配置: context: resolve('src') output: { path: resolve('b
我需要创建带有圆角的 SVG 路径,以将它们导出到 DXF 进行切割。我的问题是角应该是圆弧,而不是贝塞尔曲线。 使用 arc 命令相对容易处理直角,因为半径也是从拐角到圆弧起点的距离。对于其他角度,
大家好,我正在玩 Airflow,我正在阅读这篇很有帮助的 tutorial .我正在寻求帮助以更好地了解 Admin->Connection 如何在 Conn Type: File (path) 方
我的目标是定义R将用于安装和搜索库的单个路径。我read可以通过更改Rprofile.site安装路径中的R文件来完成。我在那里尝试了两个命令: .libPaths("D:/RLibrary") .L
我有一个问题:当我在一个页面中时,我想返回到上一页。我使用 $routeProvider。如何读取之前的 url? 我尝试在我的 Controller 中使用此代码但不起作用... angular.m
我正在尝试将一个文件从我的主干合并到一个分支(wc),并且对于看起来位于当前合并操作中不涉及的分支上的路径出现奇怪的未找到路径错误。 例如,在我们的 svn 项目中,我们有: 分行 分支 0 分支 1
我有一个树数据序列化如下: 关系:P到C是“一对多”,C到P是“一对一”。所以列 P 可能有重复的值,但列 C 有唯一的值。 P, C 1, 2 1, 3 3, 4 2, 5 4, 6 # in da
我是一名优秀的程序员,十分优秀!