Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
コレクションの文字列をコレクションに変換する方法
変数の例:
string_txt = "[id:2,name:'myname',age:'20']"
インスタンスとして使用したい:
string_txt.id >> 2 string_txt.name >> "myname" ...
Evalクラスを使用できます:
Eval
def stringTxt = "[id:2,name:'myname',age:'20']" def map = Eval.me( stringTxt ) assert map.name == 'myname'
もちろん、マップを文字列に入れる以外に別の方法がある場合は、おそらくそれを行う必要があります。テキストの評価は、大きなセキュリティ リスクになる可能性があります :-(