| 
    Formatron v0.4.11
     
     
    
   Formatron empowers everyone to control the output format of language models with minimal overhead. 
   | 
 
An extractor that loads json data to an object from a string. More...
  
Public Member Functions | |
| __init__ (self, str nonterminal, typing.Optional[str] capture_name, schemas.schema.Schema|collections.abc.Sequence schema, typing.Callable[[str], schemas.schema.Schema] to_object) | |
| Create a json extractor from a given schema or a list of supported types.   | |
| typing.Optional[tuple[str, schemas.schema.Schema]] | extract (self, str input_str) | 
| Extract a schema instance from a string.   | |
  Public Member Functions inherited from formatron.extractor.NonterminalExtractor | |
| str | nonterminal (self) | 
| Get the nonterminal of the extractor.   | |
| str | kbnf_reference (self) | 
  Public Member Functions inherited from formatron.extractor.Extractor | |
| __str__ (self) | |
| typing.Optional[str] | capture_name (self) | 
Get the name of the capture, or None if the extractor does not capture.   | |
Protected Attributes | |
| _to_object | |
| _rule_str | |
  Protected Attributes inherited from formatron.extractor.NonterminalExtractor | |
| _nonterminal | |
  Protected Attributes inherited from formatron.extractor.Extractor | |
| _capture_name | |
Properties | |
| kbnf_definition (self) | |
An extractor that loads json data to an object from a string.
| formatron.formats.json.JsonExtractor.__init__ | ( | self, | |
| str | nonterminal, | ||
| typing.Optional[str] | capture_name, | ||
| schemas.schema.Schema|collections.abc.Sequence | schema, | ||
| typing.Callable[[str], schemas.schema.Schema] | to_object ) | 
Create a json extractor from a given schema or a list of supported types.
Currently, the following data types are supported:
pattern=".*" will allow '"' to appear in the json string which is forbidden by JSON standard.substring_of="abc\"" will allow '"' to appear in the json string which is forbidden by JSON standard. Subclasses of collections.abc.Mapping[str,T] and typing.Mapping[str,T] where T is a supported type,
minItems, maxItems, prefixItems constraints| nonterminal | The nonterminal representing the extractor. | 
| capture_name | The capture name of the extractor, or None if the extractor does not capture.  | 
| schema | The schema. | 
| to_object | A callable to convert the extracted string to a schema instance. | 
Reimplemented from formatron.extractor.NonterminalExtractor.
| typing.Optional[tuple[str, schemas.schema.Schema]] formatron.formats.json.JsonExtractor.extract | ( | self, | |
| str | input_str ) | 
Extract a schema instance from a string.
| input_str | The input string to extract from. | 
None if extraction failed. Reimplemented from formatron.extractor.Extractor.
| formatron.formats.json.JsonExtractor.kbnf_definition | ( | self | ) | 
Reimplemented from formatron.extractor.Extractor.