#K7606. Extracting Integers from JSON Strings
Extracting Integers from JSON Strings
Extracting Integers from JSON Strings
You are given \( n \) lines of text representing a JSON string. This JSON string may contain integers embedded in various contexts (for example in arrays or nested objects). Your task is to extract all the integers from the provided JSON string and print them in the order they appear, separated by a single space.
Note: It is guaranteed that the input contains valid JSON-like text. There is no need to fully parse the JSON structure; you just need to find and output all the integer numbers.
For example, given the input:
6 { "name": "Sarah", "age": 28, "scores": [100, 98, 85], "details": {"height": 175, "weight": 70} }
The output should be:
28 100 98 85 175 70
inputFormat
The first line contains an integer \( n \) which denotes the number of lines that follow. The next \( n \) lines together form a JSON string.
outputFormat
Print all integers extracted from the input JSON string in the order they appear, separated by a space. If there are no integers, output an empty line.
## sample6
{
"name": "Sarah",
"age": 28,
"scores": [100, 98, 85],
"details": {"height": 175, "weight": 70}
}
28 100 98 85 175 70