What exactly are you going to use new_var for because you can export extracted name and number fields directly from the UI as JSON?
A hacky way to convert the entire quoted string of names and numbers into JSON is to essentially extract it wholesale and apply several rex commands to shape it into the correct form:
Field test : "Name:John"="21","Name:Sam"="29","Name:Jim"="40"
Search: | rex field=test mode=sed "s/(\"Name:)|(\")//g" | rex field=test mode=sed "s/=/:/g" | rex field=test mode=sed "s/^/{/" | rex field=test mode=sed "s/$/}/g"
Full example:
| stats count | eval test="\"Name:John\"=\"21\",\"Name:Sam\"=\"29\",\"Name:Jim\"=\"40\"" | rex field=test mode=sed "s/(\"Name:)|(\")//g" | rex field=test mode=sed "s/=/:/g" | rex field=test mode=sed "s/^/{/" | rex field=test mode=sed "s/$/}/g"
Output:
{John:21,Sam:29,Jim:40}
... View more