常规代码以解码base64字符串并找到特定的字符串 [英] groovy code to decode a base64 string and find a particular string

查看:178
本文介绍了常规代码以解码base64字符串并找到特定的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是groovy的新手.我正在尝试解码base64string并找出存在的特定字符串.这是编码的字符串格式

I am new to groovy. I am trying to decode a base64string and find out particular string is present it. This is the encoded string format

eyJlbmFibGU6InRydWUiLCJhcHBOYW1lIjoiQXBwIix9

在手动解码的同时我会得到

while manually decoding I will get

{"enable":"true","appName":"france24"}

由此,我需要检查appName是否等于france24. groovy代码怎么可能?

From this I need to check appName is equal to france24. How it is possible with groovy code?

推荐答案

您应该能够做到

new groovy.json.JsonSlurper().parseText(new String(encoded.decodeBase64())).appName

顺便说一句,因为您的json不能与该编码字符串一起使用

Btw, it won't work with that encoded string as your json is

{"enable:"true","appName":"App",}

哪个不是有效的json

Which isn't valid json

这篇关于常规代码以解码base64字符串并找到特定的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆