How to use JSON.parse method in Cypress

Best JavaScript code snippet using cypress

bbb.js

Source:bbb.js Github

copy

Full Screen

...99return new Promise((resolve, reject) => {100 let timestamp=new Date().getTime();101 let userInfo ={102 url: 'https://bububao.duoshoutuan.com/user/profile',103 headers: JSON.parse(CookieVal),104}105 $.post(userInfo,async(error, response, data) =>{106 const userinfo = JSON.parse(data)107 if(response.statusCode == 200 && userinfo.code != -1){108 $.log('\n🎉模擬登陸成功\n')109 notice += '🎉步步寶帳號: '+userinfo.username+'\n'+'🎉當前金幣: '+userinfo.jinbi+'💰 約'+userinfo.money+'元💸\n'110 }else{111 notice += '⚠️異常原因: '+userinfo.msg+'\n'112 }113 resolve()114 })115 })116 } 117function signIn() {118return new Promise((resolve, reject) => {119 let timestamp=new Date().getTime();120 let signin ={121 url: `https://bububao.duoshoutuan.com/user/sign`,122 headers: JSON.parse(CookieVal),123}124 $.post(signin,async(error, response, data) =>{125$.log('\n🔔開始签到\n')126 const sign = JSON.parse(data)127 if(sign.code == 1) {128 $.log('\n🎉'+sign.msg+'簽到金幣+ '+sign.jinbi+'💰\n')129 signInStr = sign.nonce_str130 await signDouble()131 }else{132 $.log('\n🎉'+sign.msg+'\n')133 }134 resolve()135 })136 })137 } 138function signDouble() {139return new Promise((resolve, reject) => {140 let timestamp=new Date().getTime();141 let signdouble ={142 url: `https://bububao.duoshoutuan.com/you/callback`,143 headers: JSON.parse(CookieVal),144 body: `nonce_str=${signInStr}&tid=2&pos=1&`,145}146 $.post(signdouble,async(error, response, data) =>{147 const signin2 = JSON.parse(data)148$.log('\n🔔開始領取每日觀看獎勵\n')149 if(signin2.code == 1) {150 $.log('\n🎉簽到翻倍成功\n')151 }else{152 $.log('\n⚠️簽到翻倍失敗敗:'+signin2.msg+'\n')153 }154 resolve()155 })156 })157 } 158function zaoWanDkInfo() {159return new Promise((resolve, reject) => {160 let timestamp=new Date().getTime();161 let zaowandkinfo ={162 url: `https://bububao.duoshoutuan.com/mini/dk_info`,163 headers: JSON.parse(CookieVal),164}165 $.post(zaowandkinfo,async(error, response, data) =>{166 const zwdkinfo = JSON.parse(data)167 if(zwdkinfo.code == 1 && zwdkinfo.is_dk == 0) {168 nowTime = zwdkinfo.now_time169 title1 = zwdkinfo.title1170 title2 = zwdkinfo.title2171 await zaoWanDk()172 }173 resolve()174 })175 })176 } 177function zaoWanDk() {178return new Promise((resolve, reject) => {179 let timestamp=new Date().getTime();180 let zaowandk ={181 url: `https://bububao.duoshoutuan.com/user/chuansj`,182 headers: JSON.parse(CookieVal),183 body: `mini_pos=3&c_type=1&`,184}185 $.post(zaowandk,async(error, response, data) =>{186 const zwdk = JSON.parse(data)187 if(zwdk.code == 1) {188 zwdkStr = zwdk.nonce_str189 await $.wait(30000)190 await dkClick()191 }192 resolve()193 })194 })195 } 196function dkClick() {197return new Promise((resolve, reject) => {198 let timestamp=new Date().getTime();199 let dkclick ={200 url: `https://bububao.duoshoutuan.com/mini/dk_click`,201 headers: JSON.parse(CookieVal),202 body: `now_time=${nowTime}&`,203}204 $.post(dkclick,async(error, response, data) =>{205 const clickdk = JSON.parse(data)206 if(clickdk.code == 1) {207 $.log('\n🎉'+clickdk.msg+'+ '+clickdk.jinbi+'💰\n')208 $.msg(`${title1}`,`${title2}`,'')209 await checkWaterNum()210 }else{211 $.log('\n⚠️'+clickdk.msg)212 await checkWaterNum()213 }214 resolve()215 })216 })217 } 218function guaList() {219return new Promise((resolve, reject) => {220 let timestamp=new Date().getTime();221 let gualist ={222 url: `https://bububao.duoshoutuan.com/gua/gualist?`,223 headers: JSON.parse(CookieVal),224}225 $.post(gualist,async(error, response, data) =>{226$.log('\n🔔開始查詢刮刮卡ID\n')227 const guaid = JSON.parse(data)228 if(guaid.ka > 0){229 for (guaId of guaid.list){230 if(guaId.is_ad == 0)231 GID = guaId.id232$.log('\n🔔查詢刮刮卡ID成功,5s後開始查询刮卡签名\n')233$.log('\nGID: '+GID+'\n')234 await $.wait(5000)235 await guaDet()236 }}else{237$.log('\n⚠️刮刮卡已用完,請明天再刮吧!\n')238 await checkWaterNum()239 }240 resolve()241 })242 })243 } 244function guaDet() {245return new Promise((resolve, reject) => {246 let timestamp=new Date().getTime();247 let guadet ={248 url: `https://bububao.duoshoutuan.com/gua/guadet?`,249 headers: JSON.parse(CookieVal),250 body: `gid=${GID}&`251}252 $.post(guadet,async(error, response, data) =>{253$.log('\n🔔開始查詢刮卡簽名\n')254 const guasign= JSON.parse(data)255 if(response.statusCode == 200) {256$.log('\n🔔查詢刮卡簽名成功\n')257 SIGN = guasign.sign258 GLID = guasign.glid259$.log('\nsign: '+SIGN+'\n')260$.log('\nglid: '+GLID+'\n')261 await guaPost()262 }263 resolve()264 })265 })266 } 267function guaPost() {268return new Promise((resolve, reject) => {269 let timestamp=new Date().getTime();270 let guapost ={271 url: `https://bububao.duoshoutuan.com/gua/guapost?`,272 headers: JSON.parse(CookieVal),273 body: `sign=${SIGN}&gid=${GID}&glid=${GLID}&`274}275 $.post(guapost,async(error, response, data) =>{276$.log('\n🔔開始刮卡\n')277 const guaka= JSON.parse(data)278 if(typeof guaka.jf === 'number') {279 guaStr = guaka.nonce_str280 $.log('\n🎉刮卡成功\n恭喜您刮出'+guaka.tp+'張相同圖案\n金幣+ '+guaka.jf+'\n等待45s後開始翻倍刮卡獎勵')281 await $.wait(45000)282 await guaDouble()283 }284 resolve()285 })286 })287 } 288function guaDouble() {289return new Promise((resolve, reject) => {290 let timestamp=new Date().getTime();291 let guadouble ={292 url: `https://bububao.duoshoutuan.com/you/callback`,293 headers: JSON.parse(CookieVal),294 body: `nonce_str=${guaStr}&tid=6&pos=1&`,295}296 $.post(guadouble,async(error, response, data) =>{297 const guaka2 = JSON.parse(data)298$.log('\n🔔開始領取刮卡翻倍獎勵\n')299 if(guaka2.code == 1) {300 $.log('\n🎉刮卡翻倍成功,等待2s後查詢下一張刮刮卡ID\n')301 await $.wait(2000)302 //await guaList()303 }else{304 $.log('\n⚠️刮卡翻倍失敗:'+guaka2.msg+'\n')305 }306 resolve()307 })308 })309 } 310function checkWaterNum() {311return new Promise((resolve, reject) => {312 let timestamp=new Date().getTime();313 let checkwaternum ={314 url: `https://bububao.duoshoutuan.com/mini/water_info`,315 headers: JSON.parse(CookieVal),316}317 $.post(checkwaternum,async(error, response, data) =>{318$.log('\n🔔開始查詢喝水杯數\n')319 const waternum = JSON.parse(data)320 if(waternum.code == 1 && waternum.day_num < 7) {321 waterNum = waternum.day_num322 if(waternum.is_sp == 1){323 $.log('\n🎉喝水前需要看廣告喔!,1s後開始看廣告\n')324 await $.wait(1000)325 await checkWaterSp()326 }else{327 $.log('\n🎉查詢成功,1s後領取喝水獎勵\n')328 await $.wait(1000)329 await waterClick()330 }}else{331 $.log('\n⚠️喝水失敗: 今日喝水已上限\n')332 }333 resolve()334 })335 })336 } 337function checkWaterSp() {338return new Promise((resolve, reject) => {339 let timestamp=new Date().getTime();340 let checksp ={341 url: `https://bububao.duoshoutuan.com/user/chuansj`,342 headers: JSON.parse(CookieVal),343 body: `mini_pos=2&c_type=1&`,344}345 $.post(checksp,async(error, response, data) =>{346 const sp = JSON.parse(data)347 if(sp.code == 1) {348 waterSpStr = sp.nonce_str349 await WaterSp()350 }351 resolve()352 })353 })354 } 355function WaterSp() {356return new Promise((resolve, reject) => {357 let timestamp=new Date().getTime();358 let watersp ={359 url: `https://bububao.duoshoutuan.com/mini/water_sp`,360 headers: JSON.parse(CookieVal),361 body: `day_num=${waterNum}&`,362}363 $.post(watersp,async(error, response, data) =>{364 const spwater = JSON.parse(data)365 if(spwater.code == 1) {366 $.log('\n🎉正在觀看喝水廣告, 30後領取喝水獎勵\n')367 await $.wait(30000)368 await waterClick()369 }370 resolve()371 })372 })373 } 374function waterClick() {375return new Promise((resolve, reject) => {376 let timestamp=new Date().getTime();377 let waterclick ={378 url: `https://bububao.duoshoutuan.com/mini/water_click`,379 headers: JSON.parse(CookieVal),380 body: `day_num=0${waterNum}&`,381}382 $.post(waterclick,async(error, response, data) =>{383 const clickwater = JSON.parse(data)384$.log('\n🔔開始領取喝水獎勵\n')385 if(clickwater.code == 1) {386 $.log('\n🎉'+clickwater.msg+'喝水金幣+ '+clickwater.jinbi+'💰\n')387 }else{388 $.log('\n⚠️喝水失敗:'+clickwater.msg+'\n')389 }390 resolve()391 })392 })393 } 394function sleepStatus() {395return new Promise((resolve, reject) => {396 let timestamp=new Date().getTime();397 let sleepstatus ={398 url: `https://bububao.duoshoutuan.com/mini/sleep_info`,399 headers: JSON.parse(CookieVal),400}401 $.post(sleepstatus,async(error, response, data) =>{402$.log('\n🔔開始查詢睡覺狀態\n')403 const slpstatus = JSON.parse(data)404 if(slpstatus.code == 1) {405 if(slpstatus.is_lq == 1 && now.getHours() >= 8 && now.getHours() <= 18) {406 sleepStr = slpstatus.nonce_str407 sleepId = slpstatus.taskid408 }else{409$.log('🔔大白天的就不要睡覺啦!')410 }411 if(slpstatus.is_sleep == 0 && slpstatus.is_lq == 1 && now.getHours() >= 20) {412$.log('🔔都幾點了,還不睡?5s後開始睡覺!')413 await $.wait(5000)414 await sleepStart()415 }else if((slpstatus.is_sleep == 1 || slpstatus.is_sleep == 0)&& slpstatus.is_lq == 0 && now.getHours() >= 8 && now.getHours() <= 12){416$.log('🔔都幾點了,還不起?5s後準備起床!')417 await $.wait(5000)418 await sleepEnd()419 }else if(slpstatus.is_sleep == 0 && slpstatus.is_lq == 1 && now.getHours() >= 8 && now.getHours() <= 12){420 await sleepDone()421 }else if(slpstatus.is_sleep == 1 && slpstatus.is_lq == 1 && now.getHours() >= 22){422 $.log('⚠️睡覺的時候不要玩手機!!!')423 }else if(slpstatus.is_sleep == 0 &&424now.getHours() >= 18){425 $.log('😘這麼早就準備睡覺了嗎?是身體不舒服嗎?要保重身體呀!')426 }}427 resolve()428 })429 })430 } 431function sleepStart() {432return new Promise((resolve, reject) => {433 let timestamp=new Date().getTime();434 let sleepstart ={435 url: `https://bububao.duoshoutuan.com/mini/sleep_start`,436 headers: JSON.parse(CookieVal),437}438 $.post(sleepstart,async(error, response, data) =>{439 const startsleep = JSON.parse(data)440$.log('\n🔔開始睡覺\n')441 if(startsleep.code == 1) {442 $.log('\n🎉睡覺成功!早睡早起身體好!\n')443 }else{444 $.log('\n⚠️睡覺失敗敗:'+startsleep.msg+'\n')445 }446 resolve()447 })448 })449 } 450function sleepEnd() {451return new Promise((resolve, reject) => {452 let timestamp=new Date().getTime();453 let sleepend ={454 url: `https://bububao.duoshoutuan.com/mini/sleep_end`,455 headers: JSON.parse(CookieVal),456}457 $.post(sleepend,async(error, response, data) =>{458 const endsleep = JSON.parse(data)459$.log('\n🔔開始起床\n')460 if(endsleep.code == 1) {461 $.log('\n🎉起床了!別睡了!\n')462 await sleepStatus()463 }else{464 $.log('\n⚠️起床失敗:'+endsleep.msg+'\n')465 }466 resolve()467 })468 })469 } 470function sleepDone() {471return new Promise((resolve, reject) => {472 let timestamp=new Date().getTime();473 let sleepdone ={474 url: `https://bububao.duoshoutuan.com/mini/sleep_done`,475 headers: JSON.parse(CookieVal),476 body: `taskid=${sleepId}&nonce_str=${sleepStr}&`477}478 $.post(sleepdone,async(error, response, data) =>{479 const donesleep = JSON.parse(data)480$.log('\n🔔開始領取睡覺金幣\n')481 if(donesleep.code == 1) {482 $.log('\n🎉'+donesleep.msg+'金幣+ '+donesleep.jinbi+'💰\n')483 }else{484 $.log('\n⚠️領取睡覺金幣失敗敗:'+donesleep.msg+'\n')485 }486 resolve()487 })488 })489 } 490function clickTaskStatus() {491return new Promise((resolve, reject) => {492 let timestamp=new Date().getTime();493 let clicktaskstatus ={494 url: `https://bububao.duoshoutuan.com/user/renwu`,495 headers: JSON.parse(CookieVal),496 body: `idfa=${JSON.parse(CookieVal)['idfa']}&`,497}498 $.post(clicktaskstatus,async(error, response, data) =>{499 const clicktask = JSON.parse(data)500 if(clicktask.first.admobile_st != 2) {501$.log('\n🔔開始查詢每日點擊任務狀態\n')502 await checkDailyClickAdId()503 }else{504 $.log('\n⚠️每日點擊廣告任務已上限\n')505 }506 resolve()507 })508 })509 } 510function watchTaskStatus() {511return new Promise((resolve, reject) => {512 let timestamp=new Date().getTime();513 let watchtaskstatus ={514 url: `https://bububao.duoshoutuan.com/user/renwu`,515 headers: JSON.parse(CookieVal),516 body: `idfa=${JSON.parse(CookieVal)['idfa']}&`,517}518 $.post(watchtaskstatus,async(error, response, data) =>{519 const watchtask = JSON.parse(data)520$.log('\n🔔開始查詢每日觀看廣告任務狀態\n')521 if(watchtask.v_st != 2) {522$.log('\n🔔每日觀看廣告任務狀態查詢成功,1s後查詢每日觀看廣告ID\n')523 await $.wait(1000)524 await checkDailyWatchAdId()525 }else{526 $.log('\n⚠️每日看廣告任務已上限\n')527 await checkWaterNum()528 }529 resolve()530 })531 })532 } 533function checkDailyWatchAdId() {534return new Promise((resolve, reject) => {535 let timestamp=new Date().getTime();536 let checkdailywatchadid ={537 url: `https://bububao.duoshoutuan.com/user/chuansj`,538 headers: JSON.parse(CookieVal),539 body: `mini_pos=0&c_type=1&`,540}541 $.post(checkdailywatchadid,async(error, response, data) =>{542$.log('\n🔔開始查詢每日觀看廣告ID\n')543 const dailywatchid = JSON.parse(data)544 if(dailywatchid.code == 1) {545 dailyWatchStr = dailywatchid.nonce_str546 // $.log('\n'+dailyWatchStr+'\n')547 $.log('\n🎉查詢成功,30s後領取獎勵\n')548 await $.wait(30000)549 await DailyWatchAd()550 }551 resolve()552 })553 })554 } 555function DailyWatchAd() {556return new Promise((resolve, reject) => {557 let timestamp=new Date().getTime();558 let dailywatchad ={559 url: `https://bububao.duoshoutuan.com/you/callback`,560 headers: JSON.parse(CookieVal),561 body: `nonce_str=${dailyWatchStr}&tid=9&pos=1&`,562}563 $.post(dailywatchad,async(error, response, data) =>{564 const dailywatch = JSON.parse(data)565$.log('\n🔔開始領取每日觀看獎勵\n')566 if(dailywatch.code == 1) {567 $.log('\n🎉每日觀看獎勵領取成功,5m(300s)後查詢下一次廣告\n')568 for(let i=1;i<=60;i++){569 (function(){570 setTimeout(() => {571 $.log('\n⏱請等待'+(60-i)*5+'s後查詢下一次廣告\n')572 }, 5000*i);573 })()574 }575 await $.wait(300000)576 await watchTaskStatus()577 }else{578 $.log('\n⚠️每日獎勵領取失敗:'+dailywatch.msg+'\n')579 }580 resolve()581 })582 })583 } 584function checkDailyClickAdId() {585return new Promise((resolve, reject) => {586 let timestamp=new Date().getTime();587 let checkdailyclickadid ={588 url: `https://bububao.duoshoutuan.com/user/admobile_show`,589 headers: JSON.parse(CookieVal),590}591 $.post(checkdailyclickadid,async(error, response, data) =>{592$.log('\n🔔開始查詢每日廣告ID\n')593 const dailyclickid = JSON.parse(data)594 if(dailyclickid.code == 1) {595 dailyClickAdId = dailyclickid.ad_id596 // $.log('\n'+dailyClickAdId+'\n')597 $.log('\n🎉查詢成功,1s後領取獎勵\n')598 await $.wait(1000)599 await checkDailyClickAd()600 }601 resolve()602 })603 })604 } 605function checkDailyClickAd() {606return new Promise((resolve, reject) => {607 let timestamp=new Date().getTime();608 let checkdailyclickad ={609 url: `https://bububao.duoshoutuan.com/user/admobile_click`,610 headers: JSON.parse(CookieVal),611 body: `ad_id=${dailyClickAdId}&`,612}613 $.post(checkdailyclickad,async(error, response, data) =>{614$.log('\n🔔開始查詢每日廣告點擊ID\n')615 const dailyclick = JSON.parse(data)616 if(dailyclick.code == 1) {617 dailyClickStr = dailyclick.nonce_str618 // $.log('\n'+dailyClickStr+'\n')619 $.log('\n🎉查詢成功,5s後返回領取獎勵\n')620 await $.wait(5000)621 await DailyClickAd()622 }623 resolve()624 })625 })626 } 627function DailyClickAd() {628return new Promise((resolve, reject) => {629 let timestamp=new Date().getTime();630 let dailyclickad ={631 url: `https://bububao.duoshoutuan.com/user/admobile_done`,632 headers: JSON.parse(CookieVal),633 body: `nonce_str=${dailyClickStr}&ad_id=${dailyClickAdId}&`,634}635 $.post(dailyclickad,async(error, response, data) =>{636 const dailyclick = JSON.parse(data)637$.log('\n🔔開始領取每日點擊獎勵\n')638 if(dailyclick.code == 1) {639 $.log('\n🎉每日點擊獎勵領取成功,1s後查詢下一次廣告ID\n')640 await $.wait(1000)641 await clickTaskStatus()642 }else{643 $.log('\n⚠️每日點擊領取失敗:'+dailyclick.msg+'\n')644 }645 resolve()646 })647 })648 } 649function checkHomeJin() {650return new Promise((resolve, reject) => {651 let timestamp=new Date().getTime();652 let checkhomejin ={653 url: 'https://bububao.duoshoutuan.com/user/home',654 headers: JSON.parse(CookieVal),655}656 $.post(checkhomejin,async(error, response, data) =>{657 const checkhomejb = JSON.parse(data)658 if(checkhomejb.right_st == 0){659 await homeJin()660 }else if(checkhomejb.right_st == 1){661$.log('\n🔔開始查詢首頁金幣狀態\n')662$.log('\n🔔等待'+(checkhomejb.right_time+5)+'s领取首页金币')663 await $.wait(checkhomejb.right_time*1000+5000)664 await homeJin()665 }else if(checkhomejb.right_st == 2 && checkhomejb.jindan_show == 0){666$.log('\n🔔開始查詢首頁金蛋狀態\n')667$.log('\n🔔等待'+(checkhomejb.jindan_djs+5)+'s领取金蛋獎勵')668 await $.wait(checkhomejb.jindan_djs*1000+5000)669 await checkGoldEggId()670 }else if(checkhomejb.right_st == 2 && checkhomejb.jindan_show == 1){671$.log('\n🔔開始查詢首頁金蛋狀態\n')672$.log('\n🔔等待'+(checkhomejb.jindan_djs+5)+'s领取金蛋獎勵')673 await $.wait(checkhomejb.jindan_djs*1000+5000)674 await checkGoldEggId()675 }else if(checkhomejb.right_st == 2 && checkhomejb.jindan_show == 2 && checkhomejb.hb_st == 0){676$.log('\n🔔開始查詢首頁紅包狀態\n')677 await checkRedBagId()678 }else if(checkhomejb.right_st == 2 && checkhomejb.jindan_show == 2 && checkhomejb.hb_st == 1){679$.log('\n🔔開始查詢首頁紅包狀態\n')680$.log('\n🔔等待'+(checkhomejb.hb_time+5)+'s領取首頁紅包')681time = checkhomejb.hb_time+5682 for(let i=1;i<=(time/5);i++){683 (function(){684 setTimeout(() => {685 $.log('\n⏱請等待'+((time/5-i)*5)+'s後領取首頁紅包\n')686 }, 5000*i);687 })()688 }689 await $.wait(checkhomejb.hb_time*1000+5000)690 await checkRedBagId()691 }else if(checkhomejb.right_st == 2 && checkhomejb.jindan_show == 2 && checkhomejb.hb_st == 2){692$.log('\n🔔首頁金幣狀態:'+checkhomejb.right_text+'\n🔔首頁紅包狀態:'+checkhomejb.hb_text+'\n🔔首頁金蛋狀態:'+checkhomejb.jindan_text+'\n')693 await checkWaterNum()694 }695 resolve()696 })697 })698 } 699function homeJin() {700return new Promise((resolve, reject) => {701 let timestamp=new Date().getTime();702 let homejin ={703 url: 'https://bububao.duoshoutuan.com/user/homejin',704 headers: JSON.parse(CookieVal),705}706 $.post(homejin,async(error, response, data) =>{707 const homejb = JSON.parse(data)708 if(homejb.code == 1){709$.log('\n🔔開始領取首頁金幣\n')710 $.log('\n🎉首頁金幣:'+homejb.msg+'\n金幣+ '+homejb.jinbi+'等待30s後開始翻倍金幣\n')711 homeJinStr = homejb.nonce_str712 //$.log('\n'+homeJinStr+'\n')713 await $.wait(30000)714 await homeJinCallBack()715 }else{716 $.log('\n⚠️首頁金幣失敗:'+homejb.msg+'\n')717 }718 resolve()719 })720 })721 } 722function homeJinCallBack() {723return new Promise((resolve, reject) => {724 let timestamp=new Date().getTime();725 let homejincallback ={726 url: `https://bububao.duoshoutuan.com/you/callback`,727 headers: JSON.parse(CookieVal),728 body: `nonce_str=${homeJinStr}&tid=21&pos=1&`,729}730 $.post(homejincallback,async(error, response, data) =>{731 const hmjcallback = JSON.parse(data)732$.log('\n🔔開始翻倍首頁金幣\n')733 if(hmjcallback.code == 1) {734 $.log('\n🎉首頁金幣翻倍成功\n')735 await checkHomeJin()736 }else{737 $.log('\n🔔首頁金幣翻倍失敗'+hmjcallback.msg+'\n')738 }739 resolve()740 })741 })742 } 743function checkRedBagId() {744return new Promise((resolve, reject) => {745 let timestamp=new Date().getTime();746 let checkredbagid ={747 url: `https://bububao.duoshoutuan.com/user/chuansj`,748 headers: JSON.parse(CookieVal),749 body: `mini_pos=0&c_type=2&`,750}751 $.post(checkredbagid,async(error, response, data) =>{752$.log('\n🔔開始查詢首頁紅包ID\n')753 const code = JSON.parse(data)754 if(code.code == 1) {755 redBagStr = code.nonce_str756$.log('\n🔔查詢首頁紅包ID成功,等待30s後領取首頁紅包\n')757 await $.wait(30000)758 await redBagCallback()759 }760 resolve()761 })762 })763 } 764function redBagCallback() {765return new Promise((resolve, reject) => {766 let timestamp=new Date().getTime();767 let redbagcallback ={768 url: `https://bububao.duoshoutuan.com/you/callback`,769 headers: JSON.parse(CookieVal),770 body: `nonce_str=${redBagStr}&tid=17&pos=1&`,771}772 $.post(redbagcallback,async(error, response, data) =>{773 const redbag = JSON.parse(data)774$.log('\n🔔開始領取首頁紅包\n')775 if(redbag.code == 1) {776 $.log('\n🎉首頁紅包領取成功\n')777 await checkHomeJin()778 }else{779 $.log('\n⚠️首頁紅包領取失敗:'+redbag.msg+'\n')780 await checkHomeJin()781 }782 resolve()783 })784 })785 } 786function checkGoldEggId() {787return new Promise((resolve, reject) => {788 let timestamp=new Date().getTime();789 let checkgoldeggid ={790 url: `https://bububao.duoshoutuan.com/user/jindan_click`,791 headers: JSON.parse(CookieVal),792}793 $.post(checkgoldeggid,async(error, response, data) =>{794 const goldeggid = JSON.parse(data)795 if(goldeggid.code == 1) {796$.log('\n🔔金蛋ID data'+data)797$.log('\n🔔開始查詢首頁金蛋ID\n')798 goldEggStr = goldeggid.nonce_str799 $.log('\n'+goldEggStr+'\n')800 goldEggId = goldeggid.taskid801 $.log('\n'+goldEggId+'\n')802 await goldEggDone()803 }else{804 $.log('\n⚠️首頁金蛋失敗:'+goldeggid.msg+'\n')805 await checkHomeJin()806 }807 resolve()808 })809 })810 } 811function goldEggDone() {812return new Promise((resolve, reject) => {813 let timestamp= Date.parse(new Date())/1000;814 let goldeggdone ={815 url: `https://bububao.duoshoutuan.com/user/jindan_done`,816 headers: JSON.parse(CookieVal),817 body: `taskid=${goldEggId}&clicktime=${timestamp}&donetime=${timestamp}+1000&nonce_str=${goldEggStr}&`818}819 $.post(goldeggdone,async(error, response, data) =>{820 const goldegg2 = JSON.parse(data)821 if(goldegg2.code == 1) {822$.log('\n🔔開始領取首頁金蛋獎勵\n')823 $.log('\n🎉首頁金蛋:'+goldegg2.msg+'\n金幣+ '+goldegg2.jinbi+'\n')824 await goldEggCallback()825 }else{826 $.log('\n⚠️首頁金蛋失敗:'+goldegg2.msg+'\n')827 await checkHomeJin()828 }829 resolve()830 })831 })832 } 833function goldEggCallback() {834return new Promise((resolve, reject) => {835 let timestamp=new Date().getTime();836 let goldeggcallback ={837 url: `https://bububao.duoshoutuan.com/you/callback`,838 headers: JSON.parse(CookieVal),839 body: `nonce_str=${goldEggStr}&tid=5&pos=1&`,840}841 $.post(goldeggcallback,async(error, response, data) =>{842 const goldeggback = JSON.parse(data)843$.log('\n🔔開始翻倍首頁金蛋\n')844 if(goldeggback.code == 1) {845 $.log('\n🎉金蛋翻倍成功\n')846 await checkHomeJin()847 }else{848 $.log('\n⚠️金蛋翻倍失敗:'+goldeggback.msg+'\n')849 await checkHomeJin()850 }851 resolve()852 })853 })854 } 855function helpStatus() {856return new Promise((resolve, reject) => {857 let timestamp=new Date().getTime();858 let helpstatus ={859 url: `https://bububao.duoshoutuan.com/user/help_index`,860 headers: JSON.parse(CookieVal),861}862 $.post(helpstatus,async(error, response, data) =>{863 const help = JSON.parse(data)864$.log('\n🔔開始查詢助力視頻狀態\n')865 if(help.status == 0) {866$.log('\n🔔查詢助力視頻狀態成功, 1s後獲取助力視頻ID\n')867 await checkCode()868 }else{869$.log('\n🔔今日助力已上限,請明天再試!\n')870 }871 resolve()872 })873 })874 } 875function checkCode() {876return new Promise((resolve, reject) => {877 let timestamp=new Date().getTime();878 let checkcode ={879 url: `https://bububao.duoshoutuan.com/user/chuansj`,880 headers: JSON.parse(CookieVal),881 body: `mini_pos=5&c_type=1&`,882}883 $.post(checkcode,async(error, response, data) =>{884 const code = JSON.parse(data)885$.log('\n🔔開始查詢助力視頻ID\n')886 if(code.code == 1) {887 nonce_str = code.nonce_str888$.log('\n🔔查詢助力視頻ID成功, 開始觀看助力視頻\n')889 await helpClick()890 }891 resolve()892 })893 })894 } 895function helpClick() {896return new Promise((resolve, reject) => {897 let timestamp=new Date().getTime();898 let helpclick ={899 url: `https://bububao.duoshoutuan.com/user/help_click`,900 headers: JSON.parse(CookieVal),901 body: `nonce_str=${nonce_str}`,902}903 $.post(helpclick,async(error, response, data) =>{904 const help = JSON.parse(data)905 if(help.code == 1) {906$.log('\n🔔開始觀看助力視頻, 60s後領取助力視頻獎勵\n')907 await $.wait(60000)908 $.log('\n🎉觀看助力視頻成功, 1s後領取金幣+ '+help.jinbi+'\n')909 await callBack()910 }else{911 $.log('\n⚠️觀看助力視頻失敗: '+help.msg+'\n')912 }913 resolve()914 })915 })916 } 917function callBack() {918return new Promise((resolve, reject) => {919 let timestamp=new Date().getTime();920 let callback ={921 url: `https://bububao.duoshoutuan.com/you/callback`,922 headers: JSON.parse(CookieVal),923 body: `nonce_str=${nonce_str}&tid=22&pos=1&`,924}925 $.post(callback,async(error, response, data) =>{926 const back = JSON.parse(data)927$.log('\n🔔開始領取助力視頻獎勵\n')928 if(back.code == 1) {929 $.log('\n🎉領取助力視頻獎勵成功,1s後查詢下一次助力視頻狀態\n')930 await $.wait(1000)931 await helpStatus()932 }else{933 $.log('\n⚠️助力視頻獎勵失敗:'+back.msg+'\n')934 }935 resolve()936 })937 })938 } 939function getNewsId() {940return new Promise((resolve, reject) => {941 let timestamp=new Date().getTime();942 let getnewsid ={943 url: 'https://bububao.duoshoutuan.com/user/news',944 headers: JSON.parse(CookieVal),945 body: `type_class=1&`946}947 $.post(getnewsid,async(error, response, data) =>{948 const newsid = JSON.parse(data)949 if(newsid.code == 1){950 if(newsid.is_first == 1 && newsid.is_max == 0){951 $.log('\n🔔開始查詢新聞ID\n')952 newsStr = newsid.nonce_str953 $.log('\n🎉新聞ID查詢成功,15s後領取閱讀獎勵\n')954 await $.wait(15000)955 await autoRead()956 }else{957 $.log('\n⚠️閱讀失敗: 今日閱讀已上限\n')958 await checkLuckNum()959 }}else{960 $.log('\n⚠️查詢新聞ID失敗:'+newsid.msg+'\n')961 }962 resolve()963 })964 })965 } 966function autoRead() {967return new Promise((resolve, reject) => {968 let timestamp=new Date().getTime();969 let autoread ={970 url: 'https://bububao.duoshoutuan.com/user/donenews',971 headers: JSON.parse(CookieVal),972 body: `nonce_str=${newsStr}& `,973}974 $.post(autoread,async(error, response, data) =>{975 const read = JSON.parse(data)976 if(read.code == 1) {977 $.log('\n🎉閱讀成功,金幣+ '+read.jinbi+'💰,開始查詢下一篇新聞ID\n')978 await getNewsId()979 }else{980 $.log('\n⚠️閱讀失敗:'+data+'\n')981 }982 resolve()983 })984 })985 } 986function checkLuckNum() {987return new Promise((resolve, reject) => {988 let timestamp=new Date().getTime();989 let lucknum ={990 url: `https://bububao.duoshoutuan.com/user/lucky`,991 headers: JSON.parse(CookieVal),992}993 $.post(lucknum,async(error, response, data) =>{994 const num = JSON.parse(data)995$.log('\n🔔開始查詢抽獎次數\n')996 if(num.lucky_num != 0) {997 $.log('\n🎉剩餘抽獎次數:'+num.lucky_num+'1s後開始抽獎\n')998 await $.wait(1000)999 await luckyClick()1000 }else if(num.lucky_num == 0) {1001 $.log('\n⚠️今日抽獎次數已用完,1s後查詢寶箱狀態\n')1002 await $.wait(1000)1003 for (box of num.lucky_box){1004 //$.log(box)1005 if (box != 2)1006 await luckyBox()1007 if (box == 2)1008 $.log('\n⚠️寶箱已開啟\n')1009 }1010 }1011 resolve()1012 })1013 })1014 } 1015function luckyClick() {1016return new Promise((resolve, reject) => {1017 let timestamp=new Date().getTime();1018 let luckclick ={1019 url: `https://bububao.duoshoutuan.com/user/lucky_click`,1020 headers: JSON.parse(CookieVal),1021}1022 $.post(luckclick,async(error, response, data) =>{1023 const lucky = JSON.parse(data)1024$.log('\n🔔開始抽獎\n')1025 if(lucky.code == 1) {1026 $.log('\n🎉抽獎:'+lucky.msg+'\n金幣+ '+lucky.jinbi+'\n')1027 luckyStr = lucky.nonce_str1028 //$.log('\n'+luckyStr+'\n')1029 if(lucky.jinbi != 0) {1030 await $.wait(5000)1031 await luckyCallBack()1032 }else{1033 await luckyClick()1034 }1035 }1036 resolve()1037 })1038 })1039 } 1040function luckyCallBack() {1041return new Promise((resolve, reject) => {1042 let timestamp=new Date().getTime();1043 let luckycallback ={1044 url: `https://bububao.duoshoutuan.com/you/callback`,1045 headers: JSON.parse(CookieVal),1046 body: `nonce_str=${luckyStr}&tid=16&pos=1&`,1047}1048 $.post(luckycallback,async(error, response, data) =>{1049 const callback = JSON.parse(data)1050$.log('\n🔔開始翻倍抽獎\n')1051 if(callback.code == 1) {1052 $.log('\n🎉抽獎翻倍成功\n')1053 await $.wait(5000)1054 await luckyClick()1055 }else{1056 $.log('\n⚠️抽獎翻倍失敗:'+callback.msg+'\n')1057 }1058 resolve()1059 })1060 })1061 } 1062function luckyBox() {1063return new Promise((resolve, reject) => {1064 let timestamp=new Date().getTime();1065 let luckybox ={1066 url: `https://bububao.duoshoutuan.com/user/lucky_box`,1067 headers: JSON.parse(CookieVal),1068 body: `box=${getBoxId()}&`,1069}1070//$.log('\nlockyboxBODY:'+luckybox.body+'\n')1071 $.post(luckybox,async(error, response, data) =>{1072 const boxlucky = JSON.parse(data)1073$.log('\n🔔開始打開寶箱\n')1074 if(boxlucky.code == 1) {1075 $.log('🎉寶箱: '+boxlucky.msg+'\n金幣+ '+boxlucky.jinbi+'\n')1076 luckyBoxStr = boxlucky.nonce_str1077 $.log('\n🔔寶箱翻倍ID'+luckyBoxStr+'\n')1078 await $.wait(5000)1079 await luckyBoxCallBack()1080 }else{1081 $.log('\n⚠️寶箱失敗:'+boxlucky.msg+'\n')1082 }1083 resolve()1084 })1085 })1086 } 1087function luckyBoxCallBack() {1088return new Promise((resolve, reject) => {1089 let timestamp=new Date().getTime();1090 let luckyboxcallback ={1091 url: `https://bububao.duoshoutuan.com/you/callback`,1092 headers: JSON.parse(CookieVal),1093 body: `nonce_str=${luckyBoxStr}&tid=16&pos=1&`,1094}1095 $.post(luckyboxcallback,async(error, response, data) =>{1096 const boxcallback = JSON.parse(data)1097$.log('\n🔔開始翻倍寶箱\n')1098 if(boxcallback.code == 1) {1099 $.log('\n🎉寶箱翻倍成功\n')1100 await $.wait(1000)1101 }else{1102 $.log('\n⚠️寶箱翻倍失敗'+boxcallback.msg+'\n')1103 }1104 resolve()1105 })1106 })1107 } 1108function getQuestionId() {1109return new Promise((resolve, reject) => {1110 let timestamp=new Date().getTime();1111 let getquestionid ={1112 url: `https://bububao.duoshoutuan.com/mini/cy_info`,1113 headers: JSON.parse(CookieVal),1114}1115 $.post(getquestionid,async(error, response, data) =>{1116 const question = JSON.parse(data)1117 if(question.code == 1 && question.day_num != 0) {1118$.log('\n🔔開始查詢答題ID\n')1119 questionSite = question.site1120 $.log('\n🎉答題ID1⃣️: '+questionSite+'\n')1121 questionId = question.cy_id1122 $.log('\n🎉答題ID2⃣️: '+questionId+'\n')1123 spId = question.day_num1124 $.log('\n🎉答題視頻: '+spId+'\n')1125 if(question.is_sp == 1) {1126 await $.wait(5000)1127 await checkSp()1128 }else{1129 await answerQue()1130 }}else{1131 $.log('\n⚠️查詢答題ID成功,答題失敗: 今日答題已上限\n')1132 }1133 resolve()1134 })1135 })1136 } 1137function checkSp() {1138return new Promise((resolve, reject) => {1139 let timestamp=new Date().getTime();1140 let checksp ={1141 url: `https://bububao.duoshoutuan.com/user/chuansj`,1142 headers: JSON.parse(CookieVal),1143 body: `mini_pos=1&c_type=1&`,1144}1145 $.post(checksp,async(error, response, data) =>{1146 const sp = JSON.parse(data)1147 if(sp.code == 1) {1148 spStr = sp.nonce_str1149 //$.log('\n'+spStr+'\n')1150 await $.wait(5000)1151 await cySp()1152 }1153 resolve()1154 })1155 })1156 } 1157function cySp() {1158return new Promise((resolve, reject) => {1159 let timestamp=new Date().getTime();1160 let cysp ={1161 url: `https://bububao.duoshoutuan.com/mini/cy_sp`,1162 headers: JSON.parse(CookieVal),1163 body: `day_num=${spId}&`,1164}1165 $.post(cysp,async(error, response, data) =>{1166 const sp = JSON.parse(data)1167 if(sp.code == 1) {1168 // $.log('\n'+sp.msg+'\n')1169 //await $.wait(5000)1170 await answerQue()1171 }1172 resolve()1173 })1174 })1175 } 1176function answerQue() {1177return new Promise((resolve, reject) => {1178 let timestamp=new Date().getTime();1179 let answerque ={1180 url: `https://bububao.duoshoutuan.com/mini/cy_click`,1181 headers: JSON.parse(CookieVal),1182 body: `cy_id=${questionId}&site=${questionSite}&`,1183}1184//$.log('\nanswerqueBODY:'+answerque.body+'\n')1185 $.post(answerque,async(error, response, data) =>{1186 const answer = JSON.parse(data)1187$.log('\n🔔開始答題\n')1188 if(answer.code == 1) {1189 $.log('\n🎉答題: '+answer.msg+'\n金幣+ '+answer.jinbi+'\n')1190 answerStr = answer.nonce_str1191 $.log('\n🎉答題翻倍ID:'+answerStr+'\n')1192 await $.wait(5000)1193 await answerQueCallBack()1194 }else{1195 $.log('\n⚠️答題失敗: '+answer.msg+'\n')1196 }1197 resolve()1198 })1199 })1200 } 1201function answerQueCallBack() {1202return new Promise((resolve, reject) => {1203 let timestamp=new Date().getTime();1204 let answerquecallback ={1205 url: `https://bububao.duoshoutuan.com/you/callback`,1206 headers: JSON.parse(CookieVal),1207 body: `nonce_str=${answerStr}&tid=18&pos=1&`,1208}1209//$.log('\nanswerQueCallBackBODY:'+answerquecallback.body+'\n')1210 $.post(answerquecallback,async(error, response, data) =>{1211 const answerback = JSON.parse(data)1212$.log('\n🔔開始翻倍答題金幣\n')1213 if(answerback.code == 1) {1214 $.log('\n🎉答題金幣翻倍成功\n')1215 await $.wait(5000)1216 await getQuestionId()1217 }else{1218 $.log('\n⚠️答題金幣翻倍失敗:'+answerback.msg+'\n')1219 }1220 resolve()1221 })1222 })1223 } 1224function checkH5Id() {1225return new Promise((resolve, reject) => {1226 let timestamp=new Date().getTime();1227 let checkh5id ={1228 url: `https://bububao.duoshoutuan.com/user/h5_list?`,1229 headers: JSON.parse(CookieVal),1230 body: `page=1&page_limit=50&`,1231}1232 $.post(checkh5id,async(error, response, data) =>{1233 const checkh5 = JSON.parse(data)1234 if(response.statusCode == 200){1235 for(ID of checkh5){1236 H5ID = ID.mini_id1237 $.log('\n'+H5ID+'\n')1238 await doTaskH5()1239 }1240 }1241 resolve()1242 })1243 })1244 } 1245function doTaskH5() {1246return new Promise((resolve, reject) => {1247 let timestamp=new Date().getTime();1248 let dotaskh5 ={1249 url: `https://bububao.duoshoutuan.com/user/h5_news?`,1250 headers: JSON.parse(CookieVal),1251 body: `mini_id=${H5ID}&`,1252}1253 $.post(dotaskh5,async(error, response, data) =>{1254 $.post(dotaskh5,async(error, response, data) =>{1255 const doh5task = JSON.parse(data)1256$.log('\ndoTaskH5:'+data+'\n')1257 if(response.body.indexOf('nonce_str') != -1) {1258 H5Str = doh5task.nonce_str1259 $.log('\n'+H5Str+'\n')1260 H5TaskID = doh5task.taskid1261 $.log('\n'+H5TaskID+'\n')1262 //await $.wait(30000)1263 await upLoadTime2()1264 }else{1265 $.log('\n'+data+'\n')1266 }1267 resolve()1268 })1269 })})1270 } 1271function upLoadTime() {1272return new Promise((resolve, reject) => {1273 let timestamp=new Date().getTime();1274 let uploadtime ={1275 url: `https://wapinformation.dfxwdc.com/wapreport/screen_show?encodedMsg=cWlkMTAyNjcJMTYxMDkxODY0MzAyMjkwNTYJbmV3cwllYXN0ZGF5X3dhcG5ld3MJanVuc2hpCWRmdHQtNzcxMjNkYWI3MC04YWFmCXRvdXRpYW8JaHR0cHM6Ly90b3V0aWFvLmVhc3RkYXkuY29tLwlqdW5zaGkJMQkxCTAJLy9taW5pLmVhc3RkYXkuY29tL21vYmlsZS8yMTAxMTYxMTU0MTE5NTU1NTE3NzcuaHRtbAl0b3V0aWFvCWp1bnNoaQ%3D%3D&_=1610918646639&jsonpcallback=Zepto${timestamp}`,1276 headers: {"Accept": "*/*","Accept-Encoding": "gzip, deflate, br","Accept-Language": "zh-cn","Connection": "keep-alive","Host": "wapunionstatis.dfxwdc.com","Referer": "https://toutiao.eastday.com/?qid=qid10267","User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148",},1277 timeout: 30000,1278}1279 $.get(uploadtime,async(error, response, data) =>{1280$.log('\nupLoadTime:'+timestamp+'\n'+data+'\n')1281 await $.wait(30000)1282 await h5Done()1283 resolve()1284 })1285 })1286 } 1287function upLoadTime2() {1288return new Promise((resolve, reject) => {1289 let timestamp=new Date().getTime();1290 let uploadtime ={1291 url: `https://api.clotfun.online/tiger/getConfig/a0d2cb8e06bd53b0530f8786624999db?hdggHtmlId=675`,1292 headers: {"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148",},1293 timeout: 30000,1294}1295 $.get(uploadtime,async(error, response, data) =>{1296$.log('\nupLoadTime2:'+data+'\n')1297 await $.wait(30000)1298 await h5Done()1299 resolve()1300 })1301 })1302 } 1303function h5Done() {1304return new Promise((resolve, reject) => {1305 let timestamp=new Date().getTime();1306 let h5done ={1307 url: `https://bububao.duoshoutuan.com/user/h5_newsdone`,1308 headers: JSON.parse(CookieVal),1309 body: `taskid=${H5TaskID}&nonce_str=${H5Str}&`,1310 timeout: 30000,1311}1312 $.post(h5done,async(error, response, data) =>{1313 const doneh5 = JSON.parse(data)1314 if(doneh5.code == 1) {1315 $.log('\n看看賺成功, 金幣+ '+ $.log('\n'+doneh5.jinbi+'\n')+'\n')1316 }else{1317 $.log('\n'+doneh5.msg+'\n')1318 }1319 resolve()1320 })1321 })1322 } ...

Full Screen

Full Screen

json-parse-coverage.js

Source:json-parse-coverage.js Github

copy

Full Screen

...31 calledFunctions: 0,32 path: "build/json-parse/json-parse.js",33 code: []34};35_yuitest_coverage["build/json-parse/json-parse.js"].code=["YUI.add('json-parse', function (Y, NAME) {","","/**"," * <p>The JSON module adds support for serializing JavaScript objects into"," * JSON strings and parsing JavaScript objects from strings in JSON format.</p>"," *"," * <p>The JSON namespace is added to your YUI instance including static methods"," * Y.JSON.parse(..) and Y.JSON.stringify(..).</p>"," *"," * <p>The functionality and method signatures follow the ECMAScript 5"," * specification. In browsers with native JSON support, the native"," * implementation is used.</p>"," *"," * <p>The <code>json</code> module is a rollup of <code>json-parse</code> and"," * <code>json-stringify</code>.</p>"," *"," * <p>As their names suggest, <code>json-parse</code> adds support for parsing"," * JSON data (Y.JSON.parse) and <code>json-stringify</code> for serializing"," * JavaScript data into JSON strings (Y.JSON.stringify). You may choose to"," * include either of the submodules individually if you don't need the"," * complementary functionality, or include the rollup for both.</p>"," *"," * @module json"," * @main json"," * @class JSON"," * @static"," */","","/**"," * Provides Y.JSON.parse method to accept JSON strings and return native"," * JavaScript objects."," *"," * @module json"," * @submodule json-parse"," * @for JSON"," * @static"," */","","","// All internals kept private for security reasons","function fromGlobal(ref) {"," var g = ((typeof global === 'object') ? global : undefined);"," return ((Y.UA.nodejs && g) ? g : (Y.config.win || {}))[ref];","}","",""," /**"," * Alias to native browser implementation of the JSON object if available."," *"," * @property Native"," * @type {Object}"," * @private"," */","var _JSON = fromGlobal('JSON'),",""," Native = (Object.prototype.toString.call(_JSON) === '[object JSON]' && _JSON),"," useNative = !!Native,",""," /**"," * Replace certain Unicode characters that JavaScript may handle incorrectly"," * during eval--either by deleting them or treating them as line"," * endings--with escape sequences."," * IMPORTANT NOTE: This regex will be used to modify the input if a match is"," * found."," *"," * @property _UNICODE_EXCEPTIONS"," * @type {RegExp}"," * @private"," */"," _UNICODE_EXCEPTIONS = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,","",""," /**"," * First step in the safety evaluation. Regex used to replace all escape"," * sequences (i.e. \"\\\\\", etc) with '@' characters (a non-JSON character)."," *"," * @property _ESCAPES"," * @type {RegExp}"," * @private"," */"," _ESCAPES = /\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,",""," /**"," * Second step in the safety evaluation. Regex used to replace all simple"," * values with ']' characters."," *"," * @property _VALUES"," * @type {RegExp}"," * @private"," */"," _VALUES = /\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,",""," /**"," * Third step in the safety evaluation. Regex used to remove all open"," * square brackets following a colon, comma, or at the beginning of the"," * string."," *"," * @property _BRACKETS"," * @type {RegExp}"," * @private"," */"," _BRACKETS = /(?:^|:|,)(?:\\s*\\[)+/g,",""," /**"," * Final step in the safety evaluation. Regex used to test the string left"," * after all previous replacements for invalid characters."," *"," * @property _UNSAFE"," * @type {RegExp}"," * @private"," */"," _UNSAFE = /[^\\],:{}\\s]/,",""," /**"," * Replaces specific unicode characters with their appropriate \\unnnn"," * format. Some browsers ignore certain characters during eval."," *"," * @method escapeException"," * @param c {String} Unicode character"," * @return {String} the \\unnnn escapement of the character"," * @private"," */"," _escapeException = function (c) {"," return '\\\\u'+('0000'+(+(c.charCodeAt(0))).toString(16)).slice(-4);"," },",""," /**"," * Traverses nested objects, applying a reviver function to each (key,value)"," * from the scope if the key:value's containing object. The value returned"," * from the function will replace the original value in the key:value pair."," * If the value returned is undefined, the key will be omitted from the"," * returned object."," *"," * @method _revive"," * @param data {MIXED} Any JavaScript data"," * @param reviver {Function} filter or mutation function"," * @return {MIXED} The results of the filtered data"," * @private"," */"," _revive = function (data, reviver) {"," var walk = function (o,key) {"," var k,v,value = o[key];"," if (value && typeof value === 'object') {"," for (k in value) {"," if (value.hasOwnProperty(k)) {"," v = walk(value, k);"," if (v === undefined) {"," delete value[k];"," } else {"," value[k] = v;"," }"," }"," }"," }"," return reviver.call(o,key,value);"," };",""," return typeof reviver === 'function' ? walk({'':data},'') : data;"," },",""," /**"," * Parse a JSON string, returning the native JavaScript representation."," *"," * @param s {string} JSON string data"," * @param reviver {function} (optional) function(k,v) passed each key value"," * pair of object literals, allowing pruning or altering values"," * @return {MIXED} the native JavaScript representation of the JSON string"," * @throws SyntaxError"," * @method parse"," * @static"," */"," // JavaScript implementation in lieu of native browser support. Based on"," // the json2.js library from http://json.org"," _parse = function (s,reviver) {"," // Replace certain Unicode characters that are otherwise handled"," // incorrectly by some browser implementations."," // NOTE: This modifies the input if such characters are found!"," s = s.replace(_UNICODE_EXCEPTIONS, _escapeException);",""," // Test for any remaining invalid characters"," if (!_UNSAFE.test(s.replace(_ESCAPES,'@')."," replace(_VALUES,']')."," replace(_BRACKETS,''))) {",""," // Eval the text into a JavaScript data structure, apply any"," // reviver function, and return"," return _revive( eval('(' + s + ')'), reviver );"," }",""," throw new SyntaxError('JSON.parse');"," };","","Y.namespace('JSON').parse = function (s,reviver) {"," if (typeof s !== 'string') {"," s += '';"," }",""," return Native && Y.JSON.useNativeParse ?"," Native.parse(s,reviver) : _parse(s,reviver);","};","","function workingNative( k, v ) {"," return k === \"ok\" ? true : v;","}","","// Double check basic functionality. This is mainly to catch early broken","// implementations of the JSON API in Firefox 3.1 beta1 and beta2","if ( Native ) {"," try {"," useNative = ( Native.parse( '{\"ok\":false}', workingNative ) ).ok;"," }"," catch ( e ) {"," useNative = false;"," }","}","","/**"," * Leverage native JSON parse if the browser has a native implementation."," * In general, this is a good idea. See the Known Issues section in the"," * JSON user guide for caveats. The default value is true for browsers with"," * native JSON support."," *"," * @property useNativeParse"," * @type Boolean"," * @default true"," * @static"," */","Y.JSON.useNativeParse = useNative;","","","}, '3.7.3', {\"requires\": [\"yui-base\"]});"];36_yuitest_coverage["build/json-parse/json-parse.js"].lines = {"1":0,"41":0,"42":0,"43":0,"54":0,"124":0,"141":0,"142":0,"143":0,"144":0,"145":0,"146":0,"147":0,"148":0,"150":0,"155":0,"158":0,"178":0,"181":0,"187":0,"190":0,"193":0,"194":0,"195":0,"198":0,"202":0,"203":0,"208":0,"209":0,"210":0,"213":0,"228":0};37_yuitest_coverage["build/json-parse/json-parse.js"].functions = {"fromGlobal:41":0,"_escapeException:123":0,"walk:141":0,"_revive:140":0,"_parse:174":0,"parse:193":0,"workingNative:202":0,"(anonymous 1):1":0};38_yuitest_coverage["build/json-parse/json-parse.js"].coveredLines = 32;39_yuitest_coverage["build/json-parse/json-parse.js"].coveredFunctions = 8;40_yuitest_coverline("build/json-parse/json-parse.js", 1);41YUI.add('json-parse', function (Y, NAME) {42/**43 * <p>The JSON module adds support for serializing JavaScript objects into44 * JSON strings and parsing JavaScript objects from strings in JSON format.</p>45 *46 * <p>The JSON namespace is added to your YUI instance including static methods47 * Y.JSON.parse(..) and Y.JSON.stringify(..).</p>48 *49 * <p>The functionality and method signatures follow the ECMAScript 550 * specification. In browsers with native JSON support, the native51 * implementation is used.</p>52 *53 * <p>The <code>json</code> module is a rollup of <code>json-parse</code> and54 * <code>json-stringify</code>.</p>55 *56 * <p>As their names suggest, <code>json-parse</code> adds support for parsing57 * JSON data (Y.JSON.parse) and <code>json-stringify</code> for serializing58 * JavaScript data into JSON strings (Y.JSON.stringify). You may choose to59 * include either of the submodules individually if you don't need the60 * complementary functionality, or include the rollup for both.</p>61 *...

Full Screen

Full Screen

json.js

Source:json.js Github

copy

Full Screen

1define(["doh/main", "../json", "../has"], function(doh, JSON, has){2 var mustThrow = function(json){3 try{4 JSON.parse(json, true);5 }catch(e){6 return;7 }8 throw new Error("Invalid JSON " + json + " should have been rejected");9 };10 doh.register("tests.json", [11 // all tests below are taken from #4.2 of the CSS3 Color Module12 function simpleString(t){ t.is("bar", JSON.parse('{"foo":"bar"}').foo); },13 function simpleTrue(t){ t.is(true, JSON.parse('{"foo":true}').foo); },14 function simpleFalse(t){ t.is(false, JSON.parse('{"foo":false}').foo); },15 function simpleNull(t){ t.is(null, JSON.parse('{"foo":null}').foo); },16 function simpleNumber(t){ t.is(3.3, JSON.parse('{"foo":3.3}', true).foo); },17 function strictString(t){ t.is("bar", JSON.parse('{"foo":"bar"}', true).foo); },18 function strictEmptyString(t){ t.is("", JSON.parse('{"foo":""}', true).foo); },19 function strictStringEsc(t){ t.is("b\n\t\"ar()", JSON.parse('{"foo":"b\\n\\t\\"ar()"}', true).foo); },20 function strictTrue(t){ t.is(true, JSON.parse('{"foo":true}', true).foo); },21 function strictFalse(t){ t.is(false, JSON.parse('{"foo":false}', true).foo); },22 function strictNull(t){ t.is(null, JSON.parse('{"foo":null}', true).foo); },23 function strictNumber(t){ t.is(3.3, JSON.parse('{"foo":3.3}', true).foo); },24 function strictNumberNeg(t){ t.is(-3.3, JSON.parse('{"foo":-3.3}', true).foo); },25 function exponentNegative(t){ t.is(3.3e-33, JSON.parse('{"foo":3.3e-33}', true).foo); },26 function exponent(t){ t.is(3.3e33, JSON.parse('{"foo":3.3e33}', true).foo); },27 function array(t){ t.is(3, JSON.parse('{"foo":[3,true,[]]}', true).foo[0]); },28 function badCall(t){ mustThrow('{"foo":alert()}'); },29 function badMath(t){ mustThrow('{"foo":3+4}'); },30 function badIndex(t){ mustThrow('{"foo":"bar"}[3]'); },31 function badKey(t){ mustThrow('{foo:"bar"}'); },32 //function badKey2(t){ mustThrow('{2:"bar"}')},33 function badUnbalanced(t){ mustThrow('['); },34 function badUnbalanced2(t){ mustThrow('}'); },35 function badType(t){ mustThrow('["foo":"bar"]'); },36 function badUnbalanced2(t){ mustThrow('}'); },37 function serializeString(t){ t.is('{"foo":"bar"}', JSON.stringify({"foo":"bar"})); },38 function serializeNull(t){ t.is('{"foo":null}', JSON.stringify({"foo":null})); },39 function serializeFunction(t){ t.is('{}', JSON.stringify({"foo":function(){}})); },40 function serializeNaN(t){ t.is('{"foo":null}', JSON.stringify({"foo":NaN})); },41 function serializeInfinity(t){ t.is('{"foo":null}', JSON.stringify({"foo":Infinity})); },42 // there is differences in how many decimals of accuracies in seconds in how Dates are serialized between browsers43 function serializeDate(t){ t.t(/1970-01-01T00:00:00.*Z/.test(JSON.parse(JSON.stringify({"foo":new Date(1)})).foo)); },44 function serializeInherited(t){45 function FooBar() { this.foo = "foo"; }46 FooBar.prototype.bar = "bar";47 t.is('{"foo":"foo"}', JSON.stringify(new FooBar()));48 },49 /*Apparently Firefox doesn't pass the key to the toJSON method*/50 function serializeToJSON(t){ t.is('{"foo":{"name":"value"}}', JSON.stringify({foo:{toJSON:function(key){return {name:"value"}; }}})); }51 ]);52 if(!has("host-rhino")){53 doh.register("tests.json.circular", [54 function serializeCircular(t){55 try{56 var a = {};57 a.a = a;58 console.log("circular: " + JSON.stringify(a));59 }catch(e){60 return;61 }62 throw new Error("stringify must throw for circular references");63 }64 ]);65 }66var smallDataSet = {67 prop1: null,68 prop2: true,69 prop3: [],70 prop4: 3.4325222223332266,71 prop5: 10003,72 prop6: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper",73 prop7: "sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum",74 prop8: "lacus. Etiam consequat scelerisque quam. Nulla facilisi. Maecenas luctus",75 prop9: "venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie",76 prop10: "tortor at ipsum. Morbi dictum rutrum magna. Sed vitae risus." +77 "Aliquam vitae enim. Duis scelerisque metus auctor est venenatis imperdiet." +78 "Fusce dignissim porta augue. Nulla vestibulum. Integer lorem nunc," +79 "ullamcorper a, commodo ac, malesuada sed, dolor. Aenean id mi in massa" +80 "bibendum suscipit. Integer eros. Nullam suscipit mauris. In pellentesque." +81 "Mauris ipsum est, pharetra semper, pharetra in, viverra quis, tellus. Etiam" +82 "purus. Quisque egestas, tortor ac cursus lacinia, felis leo adipiscing" +83 "nisi, et rhoncus elit dolor eget eros. Fusce ut quam. Suspendisse eleifend" +84 "leo vitae ligula. Nulla facilisi."85};86var smallJson = JSON.stringify(smallDataSet);87var i, mediumDataSet = [];88for(i = 0; i < 20; i++){89 mediumDataSet.push({90 prop1: null,91 prop2: true,92 prop3: false,93 prop4: 3.4325222223332266 - i,94 prop5: 10003 + i,95 prop6: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper",96 prop7: "sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum",97 prop8: "lacus. Etiam consequat scelerisque quam. Nulla facilisi. Maecenas luctus",98 prop9: "venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie",99 prop10: "tortor at ipsum. Morbi dictum rutrum magna. Sed vitae risus." +100 "Aliquam vitae enim."101 });102}103var mediumJson = JSON.stringify(mediumDataSet);104var largeDataSet = [];105for(i = 0; i < 100; i++){106 largeDataSet.push({107 prop1: null,108 prop2: true,109 prop3: false,110 prop4: 3.4325222223332266 - i,111 prop5: ["Mauris ipsum est, pharetra semper, pharetra in, viverra quis, tellus. Etiam" +112 "purus. Quisque egestas, tortor ac cursus lacinia, felis leo adipiscing",113 "nisi, et rhoncus elit dolor eget eros. Fusce ut quam. Suspendisse eleifend" +114 "leo vitae ligula. Nulla facilisi."115 ],116 prop6: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean semper",117 prop7: "sagittis velit. Cras in mi. Duis porta mauris ut ligula. Proin porta rutrum",118 prop8: "lacus. Etiam consequat scelerisque quam. Nulla facilisi. Maecenas luctus",119 prop9: "venenatis nulla. In sit amet dui non mi semper iaculis. Sed molestie",120 prop10: "tortor at ipsum. Morbi dictum rutrum magna. Sed vitae risus." +121 "Aliquam vitae enim. Duis scelerisque metus auctor est venenatis imperdiet." +122 "Fusce dignissim porta augue. Nulla vestibulum. Integer lorem nunc," +123 "ullamcorper a, commodo ac, malesuada sed, dolor. Aenean id mi in massa" +124 "bibendum suscipit. Integer eros. Nullam suscipit mauris. In pellentesque."125 });126}127var largeJson = JSON.stringify(largeDataSet);128doh.register("tests.json.performance", [129 // all tests below are taken from #4.2 of the CSS3 Color Module130 function small(){131 var i = 10000;132 while(i-->0){133 var result = JSON.parse(smallJson);134 }135 },136 function strictSmall(){137 var i = 10000;138 while(i-->0){139 var result = JSON.parse(smallJson, true);140 }141 },142 function medium(){143 var i = 1000;144 while(i-->0){145 var result = JSON.parse(mediumJson);146 }147 },148 function strictMedium(){149 var i = 1000;150 while(i-->0){151 var result = JSON.parse(mediumJson, true);152 }153 },154 function large(){155 var i = 100;156 while(i-->0){157 var result = JSON.parse(largeJson);158 }159 },160 function strictLarge(){161 var i = 100;162 while(i-->0){163 var result = JSON.parse(largeJson, true);164 }165 }166 ]);...

Full Screen

Full Screen

parse3.test.js

Source:parse3.test.js Github

copy

Full Screen

1const json = require("./parse");2describe("test json", () => {3 test("true", () => {4 expect(json.parse("true")).toBe(true)5 expect(json.parse(" true")).toBe(true)6 expect(json.parse(" \r\t\ntrue")).toBe(true)7 expect(json.parse("\r\t\n true \r\t\n ")).toBe(true)8 expect(() => json.parse("t")).toThrow()9 expect(() => json.parse("tr ue")).toThrow()10 expect(() => json.parse("tru e")).toThrow()11 expect(() => json.parse("true1")).toThrow()12 expect(() => json.parse("true 1")).toThrow()13 expect(() => json.parse("true \r1")).toThrow()14 })15 test("false", () => {16 expect(json.parse("false")).toBe(false)17 expect(json.parse(" false")).toBe(false)18 expect(json.parse(" \r\t\nfalse")).toBe(false)19 expect(json.parse("\r\t\n false \r\t\n ")).toBe(false)20 expect(() => json.parse("f")).toThrow()21 expect(() => json.parse("fa lse")).toThrow()22 expect(() => json.parse("fals e")).toThrow()23 expect(() => json.parse("false1")).toThrow()24 expect(() => json.parse("false 1")).toThrow()25 expect(() => json.parse("false \r1")).toThrow()26 })27 test("null", () => {28 expect(json.parse("null")).toBe(null)29 expect(json.parse(" null")).toBe(null)30 expect(json.parse(" \r\t\nnull")).toBe(null)31 expect(json.parse("\r\t\n null \r\t\n ")).toBe(null)32 expect(() => json.parse("n")).toThrow()33 expect(() => json.parse("nu ll")).toThrow()34 expect(() => json.parse("ss")).toThrow()35 expect(() => json.parse("null1")).toThrow()36 expect(() => json.parse("null 1")).toThrow()37 expect(() => json.parse("null \r1")).toThrow()38 expect(() => json.parse("nsull")).toThrow()39 })40 test("array", () => {41 expect(json.parse("[]")).toEqual([])42 expect(json.parse("[[]]")).toEqual([[]])43 expect(json.parse("[[],[],[]]")).toEqual([[], [], []])44 expect(json.parse("[[true ],[],[]]")).toEqual([[true], [], []])45 expect(json.parse("[true]")).toEqual([true])46 expect(json.parse("[true,false,null]")).toEqual([true, false, null])47 expect(json.parse("[ \n\r true \n, \n false \n , \n null \n ]")).toEqual([true, false, null])48 expect(() => json.parse("[[]")).toThrow()49 expect(() => json.parse("[,]")).toThrow()50 expect(() => json.parse("[false,,true]")).toThrow()51 expect(() => json.parse("[,true]")).toThrow()52 expect(() => json.parse("[,true]]")).toThrow()53 expect(() => json.parse("[[,]")).toThrow()54 expect(() => json.parse("[[],]")).toThrow()55 expect(() => json.parse("[ \n\r false \n\r , ]")).toThrow()56 expect(json.parse("[ ]")).toEqual([])57 expect(json.parse("[null]")).toEqual([null])58 expect(json.parse("[null, true ,false]")).toEqual([null, true, false])59 expect(json.parse("[true,[null,false]]")).toEqual([true, [null, false]])60 expect(() => json.parse('[')).toThrow()61 expect(() => json.parse('[,,]')).toThrow()62 expect(() => json.parse('[false]]')).toThrow()63 expect(() => json.parse('[,null \r1,]')).toThrow()64 expect(() => json.parse('[nu,]')).toThrow()65 expect(() => json.parse('[[],]')).toThrow()66 expect(() => json.parse('[true,[]')).toThrow()67 expect(() => json.parse('\n[\t]y\t')).toThrow()68 })69 test("string", () => {70 expect(json.parse('"1233"')).toBe("1233")71 expect(json.parse('" 12343"')).toBe(" 12343")72 expect(json.parse('"\\u0033 3"')).toBe("3 3")73 expect(json.parse('"\\n 0033 3"')).toBe("\n 0033 3")74 expect(json.parse('"\\\\"')).toBe("\\")75 expect(() => json.parse('" 123 3')).toThrow()76 expect(() => json.parse('" 123 3\"33 "')).toThrow()77 expect(() => json.parse('"\\s"')).toThrow()78 expect(() => json.parse('"\\ s"')).toThrow()79 expect(() => json.parse('"\\u 0033"')).toThrow()80 expect(() => json.parse('"\\"')).toThrow()81 })82 test("object", () => {83 expect(json.parse('{"key1":true ,"key2":"yahaha"}')).toEqual({ "key1": true, "key2": "yahaha" })84 expect(json.parse('{"key1":["1","2","3"] ,"key2":"yahaha"}')).toEqual({ "key1": ["1", "2", "3"], "key2": "yahaha" })85 expect(json.parse('{"key1":{"key1":true,"key2":[{"a":true,"b":false},"2","3"]} ,"key2":"yahaha"}')).toEqual({ "key1": { "key1": true, "key2": [{ "a": true, "b": false }, "2", "3"] }, "key2": "yahaha" })86 expect(() => json.parse('{key1:true ,"key2":"yahaha"}')).toThrow()87 expect(() => json.parse('{true:true ,"key2":"yahaha"}')).toThrow()88 expect(() => json.parse('{true: ,"key2":"yahaha"}')).toThrow()89 expect(() => json.parse('{ ,"key2":"yahaha"}')).toThrow()90 expect(() => json.parse('{: ,"key2":"yahaha"}')).toThrow()91 expect(() => json.parse('{}: ,"key2":"yahaha"}')).toThrow()92 expect(() => json.parse('{}{: ,"key2":"yahaha"}')).toThrow()93 expect(() => json.parse('{"key1":{{"key1":true,"key2":[{"a":true,"b":false},"2","3"]} ,"key2":"yahaha"}')).toThrow()94 expect(() => json.parse('{"key1":{{"key1":true,"key2":{[{"a":true,"b":false}, "2","3"]} , "key2":"yahaha"}')).toThrow()95 })96 test("number", () => {97 expect(json.parse('0')).toBe(0)98 expect(json.parse('123')).toBe(123)99 expect(json.parse('11.11')).toBe(11.11)100 expect(json.parse('-123')).toBe(-123)101 expect(json.parse('0.123')).toBe(0.123)102 expect(json.parse('-0.123')).toBe(-0.123)103 expect(json.parse('123e+1')).toBe(1230)104 expect(json.parse('1.23e+1')).toBe(1.23e+1)105 expect(json.parse('123e001')).toBe(1230)106 expect(json.parse('1.1e+3345')).toEqual(Infinity)107 expect(() => json.parse('-')).toThrow()108 expect(() => json.parse('-.')).toThrow()109 expect(() => json.parse('-e')).toThrow()110 expect(() => json.parse('-.e')).toThrow()111 expect(() => json.parse('.')).toThrow()112 expect(() => json.parse('1.23 e+')).toThrow()113 expect(() => json.parse('1 23')).toThrow()114 expect(() => json.parse('1.23e+a')).toThrow()115 expect(() => json.parse('0123')).toThrow()116 expect(() => json.parse('00')).toThrow()117 expect(() => json.parse('00.23')).toThrow()118 expect(() => json.parse('0.2.3')).toThrow()119 expect(() => json.parse('0e')).toThrow()120 expect(() => json.parse('123e')).toThrow()121 expect(() => json.parse('1.e')).toThrow()122 expect(() => json.parse('123e2+2')).toThrow()123 expect(() => json.parse('-123e')).toThrow()124 expect(() => json.parse('-123e+2.1e')).toThrow()125 expect(() => json.parse('123e+')).toThrow()126 expect(() => json.parse('123e+0+e')).toThrow()127 expect(() => json.parse('-0.1e+g')).toThrow()128 })...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...64 connectionmysql.query(usersql, async (err1, data1) => {65 if (err1) console.log(err1);66 var userdata = JSON.stringify(data1)67 for (var i = 0; i < data1.length; i++){68 const contact1 = await bot.Contact.find({name: JSON.parse(userdata)[i].name})69 if(JSON.parse(userdata)[i].chp == 1){70 var sql = "SELECT content FROM soul";71 connectionmysql.query(sql, async (err, data) => {72 if (err) console.log(err);73 var Range = data.length - 1;74 var Rand = Math.random();75 var id = Math.round(Rand * Range) + 1;76 var content = JSON.stringify(data)77 await contact1.say(JSON.parse(content)[id].content)78 });79 }80 if(JSON.parse(userdata)[i].wea == 1){81 var url = 'https://tianqiapi.com/api?version=v6&appid=你的appid&appsecret=你的密码&city='+ encodeURI('如皋');82 request(url, async function(err, response, body){83 var tis = "当前实时温度:"+ JSON.parse(body).tem +"℃\n"+84 "天气为:" + JSON.parse(body).wea + "\n"+85 "温度为:" + JSON.parse(body).tem2 + "℃ - " + JSON.parse(body).tem1 +"℃\n"+86 "风力等级:" + JSON.parse(body).win_speed + " \n"+87 "风速:" + JSON.parse(body).win_meter + " \n" + 88 "空气质量:" + JSON.parse(body).air + "\n" + 89 "空气质量等级:" + JSON.parse(body).air_level + "\n" + 90 "空气质量小贴士:" + JSON.parse(body).air_tips91 await contact1.say(tis)92 // console.log(JSON.parse(body).tem)//实时温度93 // console.log(JSON.parse(body).wea)//天气94 // console.log(JSON.parse(body).tem1)//白天温度(高温)95 // console.log(JSON.parse(body).tem2)//白天温度(低温)96 // console.log(JSON.parse(body).win)//风向97 // console.log(JSON.parse(body).win_speed)//风力等级98 // console.log(JSON.parse(body).win_meter)//风速99 // console.log(JSON.parse(body).air)//空气质量100 // console.log(JSON.parse(body).air_tips)//天气提示101 // console.log(JSON.parse(body).air_level)102 })103 }104 }105 })106 });107 })108 .on("message", async message => {109 if(message.self()) return ;110 const contact = message.from()111 const contact1 = await bot.Contact.find({name: contact.name()})112 var params = {113 "Query": message.text()114 }115 client.ChatBot(params).then( ...

Full Screen

Full Screen

parse1.test.js

Source:parse1.test.js Github

copy

Full Screen

1const json = require("./parse");2describe("parse litertual", () => {3 test("true", () => {4 expect((json.parse("true"))).toBe(true)5 expect((json.parse(" true \r"))).toBe(true)6 expect(() => { (json.parse("tru")) }).toThrow()7 expect(() => { (json.parse("true1")) }).toThrow()8 })9 test("false1", () => {10 expect(json.parse("false")).toBe(false)11 expect(json.parse("false\r\t ")).toBe(false)12 expect(() => { (json.parse("fals")) }).toThrow()13 expect(() => { (json.parse("false1")) }).toThrow()14 })15 test("null1", () => {16 expect(json.parse("null")).toBe(null)17 expect(json.parse("null \n")).toBe(null)18 expect(() => { (json.parse("nul")) }).toThrow()19 expect(() => { (json.parse("null1")) }).toThrow()20 })21 test("number int1", () => {22 expect(json.parse("-0")).toBe(-0)23 expect(json.parse("11")).toBe(11)24 expect(() => json.parse("012")).toThrow()25 expect(() => json.parse("-012")).toThrow()26 expect(json.parse("-1")).toBe(-1)27 expect(json.parse("0")).toBe(0)28 expect(json.parse("-11")).toBe(-11)29 expect(json.parse("1234567890")).toBe(1234567890)30 expect(json.parse("1e1")).toBe(10)31 expect(json.parse("1.1e1")).toBe(11)32 expect(json.parse("1e+1")).toBe(10)33 expect(json.parse("1.1e+1")).toBe(11)34 expect(json.parse("100e-1")).toBe(10)35 expect(json.parse("110e-1")).toBe(11)36 })37 test("number float1", () => {38 expect(json.parse("-0.1")).toBe(-0.1)39 expect(() => json.parse("01.2")).toThrow()40 expect(() => json.parse("-01.2")).toThrow()41 expect(json.parse("-0.123456789")).toBe(-0.123456789)42 expect(json.parse("0.1")).toBe(0.1)43 expect(json.parse("0.123456789")).toBe(0.123456789)44 expect(json.parse("1.23e1")).toBe(12.3)45 expect(json.parse("1.24e+1")).toBe(12.4)46 expect(json.parse("1e-1")).toBe(0.1)47 expect(json.parse("110e-3")).toBe(0.11)48 })49 test("string1", () => {50 expect(json.parse('""')).toBe("")51 expect(json.parse('"12abc"')).toBe("12abc")52 expect(json.parse('"\\r\\n\\b\\t\\f\\"\\\\\\/"')).toBe("\r\n\b\t\f\"\\/")53 expect(json.parse('"\\u0031\\u0032\\u0033abc"')).toBe("123abc")54 expect(() => json.parse('"aa')).toThrow()55 expect(() => json.parse('"\\"')).toThrow()56 expect(() => json.parse('"\\uooiu"')).toThrow()57 expect(() => json.parse('"\\o"')).toThrow()58 })59 test("array1", () => {60 expect(json.parse('[1,2]')).toEqual([1, 2])61 expect(json.parse('[ ]')).toEqual([])62 expect(json.parse('[null, true, false, "123", 1 ]')).toEqual([null, true, false, "123", 1])63 expect(() => json.parse('[')).toThrow()64 expect(() => json.parse('[1, ]')).toThrow()65 expect(json.parse('[{"a":1}, {"a":2}, {"b":1, "c":{"d":3}}]')).toEqual([{ a: 1 }, { a: 2 }, { b: 1, c: { d: 3 } }])66 })67 test("object1", () => {68 expect(json.parse("{}")).toEqual({})69 expect(json.parse('{"a": 1}')).toEqual({ a: 1 })70 expect(json.parse('{"a": "1"}')).toEqual({ a: "1" })71 expect(json.parse('{"a": null}')).toEqual({ a: null })72 expect(json.parse('{"a": true}')).toEqual({ a: true })73 expect(json.parse('{"a": false}')).toEqual({ a: false })74 expect(json.parse('{"a": "null"}')).toEqual({ a: "null" })75 expect(json.parse('{"a": "true"}')).toEqual({ a: "true" })76 expect(json.parse('{"a": "false"}')).toEqual({ a: "false" })77 expect(() => json.parse('{')).toThrow()78 expect(() => json.parse('{a, "b":1}')).toThrow()79 expect(() => json.parse('{ "b":1,}')).toThrow()80 expect(() => json.parse('{a:1}')).toThrow()81 expect(json.parse('{"a": {"a": "a"}, "b":[1,2,3]}')).toEqual({ a: { a: "a" }, b: [1, 2, 3] })82 })...

Full Screen

Full Screen

jsonfile.js

Source:jsonfile.js Github

copy

Full Screen

1const fs = require("fs")234//Storage5exports.setiker = JSON.parse(fs.readFileSync('./temp/stick.json'))6exports.audionye = JSON.parse(fs.readFileSync('./temp/vn.json'))7exports.musiknye = JSON.parse(fs.readFileSync('./temp/music.json'))8exports.imagenye = JSON.parse(fs.readFileSync('./temp/image.json'))9exports.videonye = JSON.parse(fs.readFileSync('./temp/video.json'))1011//Grup12exports.antilink = JSON.parse(fs.readFileSync('./database/antilink.json'))13exports.antivirtex = JSON.parse(fs.readFileSync('./database/antivirtex.json'))14exports.antihidetg = JSON.parse(fs.readFileSync("./database/antihidetag.json"));15exports.antivo = JSON.parse(fs.readFileSync("./database/antivo.json"));16exports.kickarea = JSON.parse(fs.readFileSync("./database/antibule.json"));17exports.welkom = JSON.parse(fs.readFileSync('./database/welkom.json'))18exports.antibug = JSON.parse(fs.readFileSync('./database/antibug.json'))19exports.antidel = JSON.parse(fs.readFileSync('./database/antidelete.json'))20exports.linkgcnya = JSON.parse(fs.readFileSync('./database/gcdetec.json'))21exports.siminya = JSON.parse(fs.readFileSync('./database/simi.json'))22exports.nsfw = JSON.parse(fs.readFileSync('./database/nsfw.json'))232425//Owner26exports.bancht = JSON.parse(fs.readFileSync('./database/banchat.json'))27exports.mute = JSON.parse(fs.readFileSync('./database/mute.json'))2829//User30exports.spamkuyy = JSON.parse(fs.readFileSync('./database/spam.json'))31exports.grupbadword = JSON.parse(fs.readFileSync('./database/grupbadword.json'));32exports.senbadword = JSON.parse(fs.readFileSync('./database/senbadword.json'));33exports.ban = JSON.parse(fs.readFileSync('./database/banned.json'))34exports.badword = JSON.parse(fs.readFileSync('./database/badword.json'))35exports.balance = JSON.parse(fs.readFileSync('./database/balance.json'));36exports.limit = JSON.parse(fs.readFileSync('./database/limit.json'));37exports.glimit = JSON.parse(fs.readFileSync('./database/glimit.json'));38exports.premium = JSON.parse(fs.readFileSync('./database/premium.json'))39exports._claim = JSON.parse(fs.readFileSync('./database/claim.json'))40exports.sewa = JSON.parse(fs.readFileSync("./database/sewa.json"))41exports.user = JSON.parse(fs.readFileSync('./database/user.json'))42exports.hitnya = JSON.parse(fs.readFileSync('./database/hitToday.json'))43exports.spamBan = JSON.parse(fs.readFileSync('./database/spamban.json'))44exports.blocked = JSON.parse(fs.readFileSync('./database/userblocked.json'))4546exports._reminder = JSON.parse(fs.readFileSync("./database/reminder.json"));47484950//List51exports.listcmdblock = JSON.parse(fs.readFileSync('./database/blockcmd.json'))52exports.listerror = JSON.parse(fs.readFileSync('./database/listerror.json'))5354exports.settings = JSON.parse(fs.readFileSync('./settings.json'))55exports.extream = JSON.parse(fs.readFileSync('./database/extream.json'))565758exports._scommand = JSON.parse(fs.readFileSync('./database/scommand.json'))5960exports.commandsDB = JSON.parse(fs.readFileSync('./database/commands.json'))6162636465666768697071727374 ...

Full Screen

Full Screen

formatter.js

Source:formatter.js Github

copy

Full Screen

1import { jsonParse } from '../formatter';2describe('jsonParse', () => {3 it('should return undefined on undefined input', () => {4 expect(jsonParse(undefined)).toBeNull();5 expect(jsonParse('{')).toBeNull();6 expect(jsonParse('hello world')).toBeNull();7 });8 it('should return parsed JSON', () => {9 expect(jsonParse('{}')).toEqual({});10 expect(jsonParse('"hello world"')).toEqual('hello world');11 expect(jsonParse(42)).toEqual(42);12 expect(jsonParse('24')).toEqual(24);13 expect(jsonParse('{ "test": "ok" }')).toEqual({14 test: 'ok',15 });16 expect(jsonParse('[2, 4, 55]')).toEqual([2, 4, 55]);17 expect(jsonParse('{ "arr": [2, 5] }')).toEqual({18 arr: [2, 5],19 });20 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', () => {2 it('test', () => {3 cy.readFile('data.json').then((data) => {4 const data1 = JSON.parse(data);5 console.log(data1);6 });7 });8});9{10 { "name": "Ford", "models": ["Fiesta", "Focus", "Mustang"] },11 { "name": "BMW", "models": ["320", "X3", "X5"] },12 { "name": "Fiat", "models": ["500", "Panda"] }13}14{ name: 'John', age: 30, cars: [ { name: 'Ford', models: [Array] }, { name: 'BMW', models: [Array] }, { name: 'Fiat', models: [Array] } ] }

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.readFile('cypress/fixtures/test.json').then((json) => {2 cy.wrap(json).as('json');3});4cy.fixture('test.json').as('json');5cy.task('readJson', 'cypress/fixtures/test.json').as('json');6Cypress.Commands.add('readJson', (filePath) => {7 return cy.readFile(filePath, 'utf-8').then((json) => {8 return JSON.parse(json);9 });10});11{12}13describe('test', () => {14 it('test', () => {15 cy.get('@json').then((json) => {16 console.log(json);17 });18 });19});20{21}22{23}24describe('test', () => {25 it('test', () => {26 cy.get('@json').then((json) => {27 console.log(json.name);28 });29 });30});31describe('test', () => {32 it('test', () => {33 cy.get('@json').then((json) => {34 console.log(json.name);35 console.log(json['name']);36 });37 });38});39describe('test', () => {40 it('test', () => {41 cy.get('@json').then((json) => {42 console.log(json.name);43 console.log(json['name']);44 console.log(json[0]);45 });46 });47});48 {49 }50describe('test', () => {51 it('test', () => {52 cy.get('@json').then((json) => {53 console.log(json[0].name);54 });55 });56});57 {58 },59 {60 }

Full Screen

Using AI Code Generation

copy

Full Screen

1const fs = require('fs')2const json = fs.readFileSync('cypress/fixtures/example.json')3const parsed = JSON.parse(json)4describe('My First Test', function() {5 it('Does not do much!', function() {6 expect(parsed).to.be.an('object')7 })8})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('JSON.parse', function() {2 it('JSON.parse', function() {3 let data = JSON.parse(response.body)4 expect(data[0].id).to.equal(1)5 })6 })7})8describe('JSON.parse', function() {9 it('JSON.parse', function() {10 let data = JSON.parse(response.body)11 expect(data[0].id).to.equal(1)12 })13 })14})15describe('JSON.parse', function() {16 it('JSON.parse', function() {17 let data = JSON.parse(response.body)18 expect(data[0].id).to.equal(1)19 })20 })21})22describe('JSON.parse', function() {23 it('JSON.parse', function() {24 let data = JSON.parse(response.body)25 expect(data[0].id).to.equal(1)26 })27 })28})29describe('JSON.parse', function() {30 it('JSON.parse', function() {31 let data = JSON.parse(response.body)32 expect(data[0].id).to.equal(1)33 })34 })35})36describe('JSON.parse', function() {37 it('JSON.parse', function() {38 let data = JSON.parse(response.body)39 expect(data[0].id).to.equal(1)40 })41 })42})43describe('JSON.parse', function() {44 it('JSON.parse', function() {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('JSON Parse', function(){2 it('JSON Parse', function(){3 cy.get('body').then((body) => {4 var data = JSON.parse(body.text())5 expect(data.userId).to.equal(1)6 expect(data.id).to.equal(1)7 expect(data.title).to.equal('delectus aut autem')8 expect(data.completed).to.equal(false)9 })10 })11})12{13}14describe('JSON Parse', function(){15 it('JSON Parse', function(){16 var data = JSON.parse(response.body)17 expect(data.userId).to.equal(1)18 expect(data.id).to.equal(1)19 expect(data.title).to.equal('delectus aut autem')20 expect(data.completed).to.equal(false)21 })22 })23})24JSON.parse(text[, reviver])25var json = '{"result":true, "count":42}'; 26obj = JSON.parse(json); 27console.log(obj.count); 28console.log(obj.result); 29Cypress JSON.parse() method

Full Screen

Using AI Code Generation

copy

Full Screen

1const data = require('./data.json');2describe('test', () => {3 it('test', () => {4 cy.log(data);5 });6});7{8}

Full Screen

Using AI Code Generation

copy

Full Screen

1const response = JSON.parse(xhr.response.body)2expect(response).to.have.property('name')3expect(response).to.have.property('job')4expect(response).to.have.property('id')5expect(response).to.have.property('createdAt')6expect(response.name).to.equal('morpheus')7expect(response.job).to.equal('leader')8expect(response.id).to.equal('1')9expect(response.createdAt).to.equal('2019-01-23T03:50:50.613Z')10})11})12})13describe('Test 2', () => {14it('should create a new user', () => {15cy.request({16body: {17}18}).then((xhr) => {19expect(xhr.status).to.equal(201)20const response = JSON.parse(xhr.response.body)21expect(response).to.have.property('name')22expect(response).to.have.property('job')23expect(response).to.have.property('id')24expect(response).to.have.property('createdAt')25expect(response.name).to.equal('morpheus')26expect(response.job).to.equal('leader')27expect(response.id).to.equal('1')28expect(response.createdAt).to.equal('2019-01-23T03:50:50.613Z')29})30})31})32describe('Test 3', () => {33it('should create a new user', () => {34cy.request({35body: {36}37}).then((xhr) => {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('JSON parse', function() {2 it('JSON parse', function() {3 .its('body')4 .then(body => {5 cy.log(JSON.parse(body)[0].name)6 })7 })8})9describe('JSON parse', function() {10 it('JSON parse', function() {11 .its('body')12 .then(body => {13 cy.log(JSON.parse(body)[0].name)14 })15 })16})17describe('JSON parse', function() {18 it('JSON parse', function() {19 .its('body')20 .then(body => {21 cy.log(JSON.parse(body)[0].name)22 })23 })24})25describe('JSON parse', function() {26 it('JSON parse', function() {27 .its('body')28 .then(body => {29 cy.log(JSON.parse(body)[0].name)30 })31 })32})33describe('JSON parse', function() {34 it('JSON parse', function() {35 .its('body')36 .then(body => {37 cy.log(JSON.parse(body)[0].name)38 })39 })40})

Full Screen

Using AI Code Generation

copy

Full Screen

1const response = require('./response.json')2const name = JSON.parse(response.body).name3console.log(name)4const response = require('./response.json')5const name = JSON.parse(response.body).name6console.log(name)7const response = require('./response.json')8const name = JSON.parse(response.body).name9console.log(name)10const response = require('./response.json')11const name = JSON.parse(response.body).name12console.log(name)13const response = require('./response.json')14const name = JSON.parse(response.body).name15console.log(name)16const response = require('./response.json')17const name = JSON.parse(response.body).name18console.log(name)19const response = require('./response.json')20const name = JSON.parse(response.body).name21console.log(name)22const response = require('./response.json

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful