Next cohort starts January 9.Apply ›

Parsing

Python Parsing Interview Questions

Parsing here means getting structured data back out of a model’s reply. A model asked for JSON returns it wrapped in a sentence or a code fence often enough that the calling code has to find the object, parse it, and then check that it holds what it claims to hold.

What parsing questions ask you to do

Across the questions here, these are the shapes that come up:

  • Find and parse the first complete JSON object in a reply
  • Ignore braces that appear inside quoted strings
  • Report which fields are missing or hold the wrong type
  • Return something sensible when there is nothing to parse
  • Pull a tool call and its arguments out of a response

Common mistakes with parsing

Taking everything between the first opening brace and the last closing one, which swallows a second object and any prose between them. Counting the braces properly means tracking whether you are inside a quoted string. On the checking side, a boolean passes a naive number test in Python, because True is an integer as far as isinstance is concerned.

Questions to practice

Roles this comes up in

Companies these come from

Other topics