Junior — Middle+
Extracting an integer from an arbitrary string
livecode
Task condition
Write a function that takes a string and returns an integer value if present. The number in the input text can be represented in two ways:
- As a direct textual representation (e.g., "42" – characters "4" and "2").
- As a JSON object with a "value" field containing the number (e.g., "{"value": 42}"). The string may also include arbitrary "junk" – any other characters. If the number cannot be extracted, the function should return None. Bonus: Implement the solution in an object-oriented style, using polymorphism for different input data formats.