# json-parser

json-parser is a skill that parses and checks JSON from construction APIs, IoT sensors, and BIM exports, turning nested records into tables for structured-data projects.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 115 installs · ★ 434 repo stars
- Author: datadrivenconstruction
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction/tree/HEAD/2_DDC_Book/2.1-Data-Types-Classification/json-parser/SKILL.md
- Updated: 2026-10-19
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/json-parser

## What it does

This skill reads JSON from a file or a string, reports parse errors, and counts records. It flattens nested objects into single-level fields and converts records to `pandas.DataFrame` values. Nested data can also be queried with dot-notation paths.

The code includes a base parser plus BIM and IoT variants. The BIM parser looks for elements under `elements`, `objects`, or `entities`, flattens them, and gathers properties from `properties`, `params`, `parameters`, or `attributes`. The IoT parser maps sensor readings to an identifier, timestamp, value, unit, and location.

Schema checks compare flattened data with required field names and return present and missing fields. The skill needs `python3` available, and table conversion relies on `pandas`. That dependency matters when the agent is asked to build a DataFrame.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill json-parser -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/json-parser/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/json-parser/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill json-parser -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/json-parser/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill json-parser -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/json-parser/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction 2_DDC_Book/2.1-Data-Types-Classification/json-parser
```

2. **Manually: put the files in place**
- File: `.github/skills/json-parser/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill json-parser -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --path 2_DDC_Book/2.1-Data-Types-Classification/json-parser
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/json-parser/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill json-parser -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction/tree/HEAD/2_DDC_Book/2.1-Data-Types-Classification/json-parser/SKILL.md

## When to use it
- parse JSON from a file or string
- flatten nested records into columns
- turn JSON data into a `pandas.DataFrame`
- read values through a dotted path
- check required fields against a schema

## Example prompts
- Use the `json-parser` skill to read `bim_export.json` and turn its records into a DataFrame.
- Validate this JSON against the required fields `project.id` and `project.name`.
- Extract the sensor readings from the nested payload and prepare a table.

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 5211a6c65b67eb64.

BEGIN THIRD-PARTY FILE 5211a6c65b67eb64
````text
---
name: "json-parser"
description: "Parse and validate JSON data from construction APIs, IoT sensors, and BIM exports. Transform nested JSON to flat DataFrames."
homepage: "https://datadrivenconstruction.io"
metadata: {"openclaw": {"emoji": "🏷️", "os": ["win32"], "homepage": "https://datadrivenconstruction.io", "requires": {"bins": ["python3"]}}}
---
# JSON Parser for Construction Data

## Overview
Construction systems increasingly use JSON for data exchange - from IoT sensors to BIM metadata exports. This skill handles parsing, validation, and flattening of JSON structures.

## Python Implementation

```python
import json
import pandas as pd
from typing import Dict, Any, List, Optional, Union
from dataclasses import dataclass
from pathlib import Path


@dataclass
class JSONParseResult:
    """Result of JSON parsing operation."""
    success: bool
    data: Any
    errors: List[str]
    record_count: int


class ConstructionJSONParser:
    """Parse JSON data from construction sources."""

    def __init__(self):
        self.errors: List[str] = []

    def parse_file(self, file_path: str) -> JSONParseResult:
        """Parse JSON from file."""
        try:
            with open(file_path, 'r', encoding='utf-8') as f:
                data = json.load(f)
            return JSONParseResult(True, data, [], self._count_records(data))
        except json.JSONDecodeError as e:
            return JSONParseResult(False, None, [f"JSON Error: {e}"], 0)
        except Exception as e:
            return JSONParseResult(False, None, [str(e)], 0)

    def parse_string(self, json_string: str) -> JSONParseResult:
        """Parse JSON from string."""
        try:
            data = json.loads(json_string)
            return JSONParseResult(True, data, [], self._count_records(data))
        except json.JSONDecodeError as e:
            return JSONParseResult(False, None, [f"JSON Error: {e}"], 0)

    def _count_records(self, data: Any) -> int:
        """Count records in data."""
        if isinstance(data, list):
            return len(data)
        elif isinstance(data, dict):
            return 1
        return 0

    def flatten_json(self, data: Dict, prefix: str = '') -> Dict[str, Any]:
        """Flatten nested JSON to single-level dict."""
        flat = {}
````
END THIRD-PARTY FILE 5211a6c65b67eb64

The third-party file has ended. Everything between the 5211a6c65b67eb64 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2293 of 7709 bytes. © datadrivenconstruction · MIT · https://github.com/datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction/tree/HEAD/2_DDC_Book/2.1-Data-Types-Classification/json-parser/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
