45 lines
3.7 KiB
XML
45 lines
3.7 KiB
XML
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 620" role="img" aria-labelledby="title desc">
|
|
<title id="title">Диагностика JSON-ответа API</title>
|
|
<desc id="desc">Сырой ответ разбирается функцией json_decode, затем проверяется json_last_error, а при успехе — тип и обязательные поля контракта.</desc>
|
|
<defs>
|
|
<linearGradient id="json-bg" x1="0" y1="0" x2="1" y2="1">
|
|
<stop offset="0" stop-color="#173a46"/>
|
|
<stop offset="1" stop-color="#245f55"/>
|
|
</linearGradient>
|
|
<marker id="json-arrow" markerWidth="10" markerHeight="10" refX="9" refY="5" orient="auto">
|
|
<path d="M0 0 L10 5 L0 10z" fill="#f2d38d"/>
|
|
</marker>
|
|
</defs>
|
|
<rect width="1200" height="620" rx="34" fill="url(#json-bg)"/>
|
|
<text x="72" y="86" fill="#fcf7e8" font-family="Arial, sans-serif" font-size="32" font-weight="700">«null» и ошибка синтаксиса — не один случай</text>
|
|
<text x="72" y="124" fill="#c2dfd2" font-family="Arial, sans-serif" font-size="19">Сначала проверяем корректность JSON, потом — договор конкретного endpoint</text>
|
|
<g font-family="Arial, sans-serif">
|
|
<rect x="68" y="242" width="208" height="122" rx="19" fill="#d4e8ff"/>
|
|
<text x="112" y="289" fill="#244868" font-size="23" font-weight="700">Сырой ответ</text>
|
|
<text x="102" y="323" fill="#244868" font-size="17">строка + размер</text>
|
|
<path d="M276 303 H386" fill="none" stroke="#f2d38d" stroke-width="5" marker-end="url(#json-arrow)"/>
|
|
<rect x="407" y="242" width="202" height="122" rx="19" fill="#f2d38d"/>
|
|
<text x="440" y="289" fill="#4a3b21" font-size="23" font-weight="700">json_decode</text>
|
|
<text x="446" y="323" fill="#4a3b21" font-size="17">без догадок</text>
|
|
<path d="M609 303 H716" fill="none" stroke="#f2d38d" stroke-width="5" marker-end="url(#json-arrow)"/>
|
|
<rect x="737" y="242" width="192" height="122" rx="19" fill="#b8e8e0"/>
|
|
<text x="771" y="289" fill="#204944" font-size="22" font-weight="700">json_last_error</text>
|
|
<text x="776" y="323" fill="#204944" font-size="17">JSON_ERROR_NONE?</text>
|
|
<path d="M833 364 V452 H609" fill="none" stroke="#f2d38d" stroke-width="5" marker-end="url(#json-arrow)"/>
|
|
<text x="780" y="414" fill="#f2d38d" font-size="16">нет</text>
|
|
<rect x="408" y="449" width="204" height="104" rx="19" fill="#f5c5bb"/>
|
|
<text x="438" y="491" fill="#61332d" font-size="21" font-weight="700">decode error</text>
|
|
<text x="431" y="523" fill="#61332d" font-size="16">код + хеш тела</text>
|
|
<path d="M929 303 H1000" fill="none" stroke="#f2d38d" stroke-width="5" marker-end="url(#json-arrow)"/>
|
|
<text x="948" y="281" fill="#f2d38d" font-size="16">да</text>
|
|
<rect x="1021" y="242" width="125" height="122" rx="19" fill="#e2d5ff"/>
|
|
<text x="1047" y="286" fill="#4c376c" font-size="20" font-weight="700">Контракт</text>
|
|
<text x="1036" y="320" fill="#4c376c" font-size="16">тип и поля</text>
|
|
<path d="M1083 364 V452 H1000" fill="none" stroke="#f2d38d" stroke-width="5" marker-end="url(#json-arrow)"/>
|
|
<rect x="797" y="449" width="204" height="104" rx="19" fill="#f5c5bb"/>
|
|
<text x="823" y="491" fill="#61332d" font-size="21" font-weight="700">contract error</text>
|
|
<text x="830" y="523" fill="#61332d" font-size="16">валидный JSON</text>
|
|
</g>
|
|
<text x="72" y="584" fill="#c2dfd2" font-family="Arial, sans-serif" font-size="18">Не пишем тело в общий журнал: размер и SHA-256 достаточно сравнить два ответа.</text>
|
|
</svg>
|