Express Your Expectations: A Fast, Compliant JSON Pull Parser for Writing Robust Applications
CppCon 2023-10-03 1tc::json::parser Extract some JSON members tc nlohmann RapidJSON Boost.JSON simdjson 0 10 20 30 40 Library Time in ms fully validating pull parser fast, O(1) memory usage implicitly y Jonathan Müller — @foonathan Express your expectations CppCon 2023-10-03 2(JSON) Parser design What is a parser? Jonathan Müller — @foonathan Express your expectations CppCon 2023-10-03 3Javascript "talks": [ { "title": "Express your expectations", "subtitle": "A fast, compliant JSON pull parser..." } ] } Jonathan Müller — @foonathan Express your expectations CppCon 2023-10-03 7JSON grammar0 码力 | 143 页 | 736.91 KB | 5 月前3Expressive Compile-time Parsers
In a compiler: tokens -> parser -> syntax tree In a web browser: text -> JSON parser -> JS object parse(text or tokens) -> value or errorParser Combinators Create a parser by combining existing parsers parse_int(text, pos) parse_string_or_int -> parse_string | parse_int Simplified syntax:Parser Generators Create a parser from a grammar. Popular parsing algorithms used in generators are LL, LL(k), LR, LR(k) Example – Boost Spirit Boost Spirit library has a DSL for creating parsers. Example code from XML parser: text %= lexeme[+(char_ - '<')]; node %= xml | text; start_tag %= '<' >> !lit('/') >> lexeme[+(char_0 码力 | 134 页 | 1.73 MB | 5 月前3Flask-RESTful Documentation Release 0.3.6
Required Arguments Multiple Values & Lists Other Destinations Argument Locations Multiple Locations Parser Inheritance Error Handling Error Messages Output Fields Basic Usage Renaming Attributes Default from flask_restful import reqparse parser = reqparse.RequestParser() parser.add_argument('rate', type=int, help='Rate to charge for this resource') args = parser.parse_args() Note Unlike the argparse strict=True ensures that an error is thrown if the request includes arguments your parser does not define. args = parser.parse_args(strict=True) Data Formatting By default, all fields in your return iterable0 码力 | 49 页 | 91.90 KB | 1 年前3Flask-RESTful Documentation Release 0.3.6
from flask_restful import reqparse parser = reqparse.RequestParser() parser.add_argument('rate', type=int, help='Rate to charge for this resource') args = parser.parse_args() Note: Unlike the argparse strict=True ensures that an error is thrown if the request includes arguments your parser does not define. args = parser.parse_args(strict=True) 1.2.5 Data Formatting By default, all fields in your return todo_id not in TODOS: abort(404, message="Todo {} doesn't exist".format(todo_id)) parser = reqparse.RequestParser() parser.add_argument('task') # Todo # shows a single todo item and lets you delete a todo0 码力 | 46 页 | 245.60 KB | 1 年前3Flask-RESTful Documentation Release 0.3.10
Required Arguments Multiple Values & Lists Other Destinations Argument Locations Multiple Locations Parser Inheritance Error Handling Error Messages Output Fields Basic Usage Renaming Attributes Default from flask_restful import reqparse parser = reqparse.RequestParser() parser.add_argument('rate', type=int, help='Rate to charge for this resource') args = parser.parse_args() Note Unlike the argparse strict=True ensures that an error is thrown if the request includes arguments your parser does not define. args = parser.parse_args(strict=True) Data Formatting By default, all fields in your return iterable0 码力 | 42 页 | 84.60 KB | 1 年前3Flask-RESTful Documentation Release 0.3.8
Required Arguments Multiple Values & Lists Other Destinations Argument Locations Multiple Locations Parser Inheritance Error Handling Error Messages Output Fields Basic Usage Renaming Attributes Default from flask_restful import reqparse parser = reqparse.RequestParser() parser.add_argument('rate', type=int, help='Rate to charge for this resource') args = parser.parse_args() Note Unlike the argparse strict=True ensures that an error is thrown if the request includes arguments your parser does not define. args = parser.parse_args(strict=True) Data Formatting By default, all fields in your return iterable0 码力 | 55 页 | 93.30 KB | 1 年前3Flask-RESTful Documentation Release 0.3.7
Required Arguments Multiple Values & Lists Other Destinations Argument Locations Multiple Locations Parser Inheritance Error Handling Error Messages Output Fields Basic Usage Renaming Attributes Default from flask_restful import reqparse parser = reqparse.RequestParser() parser.add_argument('rate', type=int, help='Rate to charge for this resource') args = parser.parse_args() Note Unlike the argparse strict=True ensures that an error is thrown if the request includes arguments your parser does not define. args = parser.parse_args(strict=True) Data Formatting By default, all fields in your return iterable0 码力 | 55 页 | 93.21 KB | 1 年前3Flask-RESTful Documentation Release 0.3.7
from flask_restful import reqparse parser = reqparse.RequestParser() parser.add_argument('rate', type=int, help='Rate to charge for this resource') args = parser.parse_args() Note: Unlike the argparse strict=True ensures that an error is thrown if the request includes arguments your parser does not define. args = parser.parse_args(strict=True) 1.2.5 Data Formatting By default, all fields in your return todo_id not in TODOS: abort(404, message="Todo {} doesn't exist".format(todo_id)) parser = reqparse.RequestParser() parser.add_argument('task') # Todo # shows a single todo item and lets you delete a todo0 码力 | 50 页 | 253.09 KB | 1 年前3Flask-RESTful Documentation Release 0.3.8
from flask_restful import reqparse parser = reqparse.RequestParser() parser.add_argument('rate', type=int, help='Rate to charge for this resource') args = parser.parse_args() Note: Unlike the argparse strict=True ensures that an error is thrown if the request includes arguments your parser does not define. args = parser.parse_args(strict=True) 1.2.5 Data Formatting By default, all fields in your return todo_id not in TODOS: abort(404, message="Todo {} doesn't exist".format(todo_id)) parser = reqparse.RequestParser() parser.add_argument('task') # Todo # shows a single todo item and lets you delete a todo0 码力 | 50 页 | 253.64 KB | 1 年前3Flask-RESTful Documentation Release 0.3.10
from flask_restful import reqparse parser = reqparse.RequestParser() parser.add_argument('rate', type=int, help='Rate to charge for this resource') args = parser.parse_args() Note: Unlike the argparse strict=True ensures that an error is thrown if the request includes arguments your parser does not define. args = parser.parse_args(strict=True) 1.2.5 Data Formatting By default, all fields in your return todo_id not in TODOS: abort(404, message="Todo {} doesn't exist".format(todo_id)) parser = reqparse.RequestParser() parser.add_argument('task') # Todo # shows a single todo item and lets you delete a todo0 码力 | 39 页 | 212.29 KB | 1 年前3
共 1000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 100