본문으로 건너뛰기
cccskills
무료GitHub에 공개

json-file

Guildlines for handling json files

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md2.5 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

JSON Handling Specifications

Goals

  • Safely parse JSON/JSONL without memory overflow.
  • Discover schema structure (keys, nesting depth, data types).
  • Flatten complex nested structures into tabular data when necessary.
  • Handle inconsistent schemas and "dirty" JSON (e.g., trailing commas, mixed types).

Inspection (Always First)

  • Structure Discovery:
    • Determine if the root is a list or a dict.
    • Identify if it's a standard JSON or JSONL (one valid JSON object per line).
  • Schema Sampling:
    • For large files, read the first few objects/lines to infer the schema.
    • Identify top-level keys and their types.
    • Detect nesting depth: If depth > 3, consider it a "deeply nested" structure.
  • Size Check:
    • If the file is large (>50MB), avoid json.load(). Use iterative parsing or streaming.

Processing & Extraction

  • Lazy Loading (Streaming):
    • For massive JSON: Use ijson (Python) or similar streaming parsers to yield specific paths/items.
    • For JSONL: Read line-by-line using a generator to minimize memory footprint.
  • Flattening & Normalization:
    • Use pandas.json_normalize to convert nested structures into flat tables if the goal is analysis.
    • Specify max_level during normalization to prevent "column explosion."
  • Data Filtering:
    • Extract only required sub-trees (keys) early in the process to reduce the memory object size.

Data Quality & Schema Validation

  • Missing Keys: Use .get(key, default) or try-except blocks. Never assume a key exists in all objects.
  • Type Coercion:
    • Validate numeric strings vs. actual numbers.
    • Standardize null, "", and [] consistently.
  • Encoding: Default to UTF-8; check for BOM (utf-8-sig) if parsing fails.
  • Malformed JSON Recovery:
    • For minor syntax errors (e.g., single quotes instead of double), attempt ast.literal_eval or regex-based cleanup only as a fallback.

Best Practices

  • Minimal Reads: Don't load a 50MB JSON just to read one config key; use a streaming approach.
  • Schema Logging: Document the detected structure (e.g., "Root is a list of 500 objects; key 'metadata' is nested").
  • Error Transparency: When a JSON object in a JSONL stream is corrupted, log the line number, skip it, and continue instead of crashing the entire process.
  • Avoid Over-Flattening: Be cautious with deeply nested arrays; flattening them can lead to massive row duplication.
  • Strict Typing: After extraction, explicitly convert types (e.g., pd.to_datetime) to ensure downstream reliability.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Guidelines for handling CSV/Excel files

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

agentscope-ai/agentscope-samples3512026년 4월 10일 업데이트

database

무료

Guidelines for handling databases

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

agentscope-ai/agentscope-samples3512026년 4월 10일 업데이트

Guidelines for handling image files

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

agentscope-ai/agentscope-samples3512026년 4월 10일 업데이트

text-file

무료

Guidelines for handling text files

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

agentscope-ai/agentscope-samples3512026년 4월 10일 업데이트

agentscope-ai의 스킬 모두 보기

이 스킬의 문제 신고