Loading an ugly input.

Could anyone tell me how to load this input in the most elegant way possible ? I just need to know how to load it and possibly when the input is not in the given format ( does not start with '[' or there's not ',' or it does not start and end with '{' , '}' it should print: "Invalid input". I was thinking of using cin load 1st bracket then ask if it's a '{' then load [x,y], ( with cin and stop when format[5] == '}' ) in this format becuase cin reads everything untill space, change numbers to int and save it to array or vector but i just think it's kind of stupid way of dealing with this problem and there must be something simple and elegant. I'll be really thankful.

 
 { [1, 1], [2, 10] , [-10, 20] }
This "ugly" input looks like JSON.
One way would be to look for an JSON library.
http://www.cplusplus.com/forum/general/38883/

Another option would be regular expressions.
http://www.cplusplus.com/reference/regex/
Topic archived. No new replies allowed.