Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert a string to an integer in jsonnet?

Tags:

json

jsonnet

I have a string that contains a number in a Jsonnet variable. How do I convert it to an integer?

like image 576
kgraney Avatar asked Jul 02 '16 06:07

kgraney


1 Answers

Jsonnet's standard library provides a: std.parseInt(str) function that can parse a signed decimal integer from a given input string. For example:

std.parseInt("123") // yields 123
std.parseInt("-456") // yields -456

Reference: http://jsonnet.org/docs/stdlib.html

like image 114
mohitsoni Avatar answered Nov 15 '22 05:11

mohitsoni