← Back to Skills Marketplace
datadrivenconstruction

Json Parser

win32 ⚠ suspicious
1511
Downloads
0
Stars
5
Active Installs
2
Versions
Install in OpenClaw
/install json-parser
Description
Parse and validate JSON data from construction APIs, IoT sensors, and BIM exports. Transform nested JSON to flat DataFrames.
README (SKILL.md)

\r

JSON Parser for Construction Data\r

\r

Overview\r

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.\r \r

Python Implementation\r

\r

import json\r
import pandas as pd\r
from typing import Dict, Any, List, Optional, Union\r
from dataclasses import dataclass\r
from pathlib import Path\r
\r
\r
@dataclass\r
class JSONParseResult:\r
    """Result of JSON parsing operation."""\r
    success: bool\r
    data: Any\r
    errors: List[str]\r
    record_count: int\r
\r
\r
class ConstructionJSONParser:\r
    """Parse JSON data from construction sources."""\r
\r
    def __init__(self):\r
        self.errors: List[str] = []\r
\r
    def parse_file(self, file_path: str) -> JSONParseResult:\r
        """Parse JSON from file."""\r
        try:\r
            with open(file_path, 'r', encoding='utf-8') as f:\r
                data = json.load(f)\r
            return JSONParseResult(True, data, [], self._count_records(data))\r
        except json.JSONDecodeError as e:\r
            return JSONParseResult(False, None, [f"JSON Error: {e}"], 0)\r
        except Exception as e:\r
            return JSONParseResult(False, None, [str(e)], 0)\r
\r
    def parse_string(self, json_string: str) -> JSONParseResult:\r
        """Parse JSON from string."""\r
        try:\r
            data = json.loads(json_string)\r
            return JSONParseResult(True, data, [], self._count_records(data))\r
        except json.JSONDecodeError as e:\r
            return JSONParseResult(False, None, [f"JSON Error: {e}"], 0)\r
\r
    def _count_records(self, data: Any) -> int:\r
        """Count records in data."""\r
        if isinstance(data, list):\r
            return len(data)\r
        elif isinstance(data, dict):\r
            return 1\r
        return 0\r
\r
    def flatten_json(self, data: Dict, prefix: str = '') -> Dict[str, Any]:\r
        """Flatten nested JSON to single-level dict."""\r
        flat = {}\r
        for key, value in data.items():\r
            new_key = f"{prefix}_{key}" if prefix else key\r
\r
            if isinstance(value, dict):\r
                flat.update(self.flatten_json(value, new_key))\r
            elif isinstance(value, list):\r
                if all(isinstance(i, (str, int, float, bool, type(None))) for i in value):\r
                    flat[new_key] = value\r
                else:\r
                    for i, item in enumerate(value):\r
                        if isinstance(item, dict):\r
                            flat.update(self.flatten_json(item, f"{new_key}_{i}"))\r
                        else:\r
                            flat[f"{new_key}_{i}"] = item\r
            else:\r
                flat[new_key] = value\r
        return flat\r
\r
    def to_dataframe(self, data: Union[List[Dict], Dict]) -> pd.DataFrame:\r
        """Convert JSON data to DataFrame."""\r
        if isinstance(data, list):\r
            flat_records = [self.flatten_json(r) if isinstance(r, dict) else {'value': r} for r in data]\r
            return pd.DataFrame(flat_records)\r
        elif isinstance(data, dict):\r
            if all(isinstance(v, list) for v in data.values()):\r
                # Dict of lists - columnar format\r
                return pd.DataFrame(data)\r
            else:\r
                flat = self.flatten_json(data)\r
                return pd.DataFrame([flat])\r
        return pd.DataFrame()\r
\r
    def extract_elements(self, data: Dict, path: str) -> List[Any]:\r
        """Extract elements using dot notation path."""\r
        parts = path.split('.')\r
        current = data\r
\r
        for part in parts:\r
            if isinstance(current, dict) and part in current:\r
                current = current[part]\r
            elif isinstance(current, list) and part.isdigit():\r
                current = current[int(part)]\r
            else:\r
                return []\r
\r
        return current if isinstance(current, list) else [current]\r
\r
    def validate_schema(self, data: Dict,\r
                        required_fields: List[str]) -> Dict[str, Any]:\r
        """Validate JSON against required fields."""\r
        flat = self.flatten_json(data)\r
        missing = [f for f in required_fields if f not in flat]\r
        present = [f for f in required_fields if f in flat]\r
\r
        return {\r
            'valid': len(missing) == 0,\r
            'missing_fields': missing,\r
            'present_fields': present,\r
            'completeness': len(present) / len(required_fields) * 100\r
        }\r
\r
\r
# BIM JSON Parser\r
class BIMJSONParser(ConstructionJSONParser):\r
    """Specialized parser for BIM JSON exports."""\r
\r
    def parse_bim_elements(self, data: Dict) -> pd.DataFrame:\r
        """Parse BIM elements from JSON export."""\r
        elements = []\r
\r
        # Common BIM JSON structures\r
        if 'elements' in data:\r
            elements = data['elements']\r
        elif 'objects' in data:\r
            elements = data['objects']\r
        elif 'entities' in data:\r
            elements = data['entities']\r
        elif isinstance(data, list):\r
            elements = data\r
\r
        if not elements:\r
            return pd.DataFrame()\r
\r
        # Flatten each element\r
        flat_elements = []\r
        for elem in elements:\r
            if isinstance(elem, dict):\r
                flat = self.flatten_json(elem)\r
                flat_elements.append(flat)\r
\r
        return pd.DataFrame(flat_elements)\r
\r
    def extract_properties(self, element: Dict) -> Dict[str, Any]:\r
        """Extract properties from BIM element."""\r
        props = {}\r
\r
        # Common property locations in BIM JSON\r
        for key in ['properties', 'params', 'parameters', 'attributes']:\r
            if key in element and isinstance(element[key], dict):\r
                props.update(element[key])\r
\r
        return props\r
\r
\r
# IoT JSON Parser\r
class IoTJSONParser(ConstructionJSONParser):\r
    """Parser for IoT sensor data."""\r
\r
    def parse_sensor_reading(self, data: Dict) -> Dict[str, Any]:\r
        """Parse single sensor reading."""\r
        return {\r
            'sensor_id': data.get('sensor_id') or data.get('id'),\r
            'timestamp': data.get('timestamp') or data.get('time'),\r
            'value': data.get('value') or data.get('reading'),\r
            'unit': data.get('unit', ''),\r
            'location': data.get('location', '')\r
        }\r
\r
    def parse_sensor_batch(self, data: List[Dict]) -> pd.DataFrame:\r
        """Parse batch of sensor readings."""\r
        readings = [self.parse_sensor_reading(r) for r in data]\r
        return pd.DataFrame(readings)\r
```\r
\r
## Quick Start\r
\r
```python\r
parser = ConstructionJSONParser()\r
\r
# Parse from file\r
result = parser.parse_file("bim_export.json")\r
if result.success:\r
    df = parser.to_dataframe(result.data)\r
    print(f"Loaded {len(df)} records")\r
\r
# Flatten nested JSON\r
flat = parser.flatten_json(result.data)\r
\r
# Extract specific path\r
elements = parser.extract_elements(result.data, "project.building.floors")\r
```\r
\r
## Common Use Cases\r
\r
### 1. BIM Metadata\r
```python\r
bim_parser = BIMJSONParser()\r
result = bim_parser.parse_file("revit_export.json")\r
elements = bim_parser.parse_bim_elements(result.data)\r
```\r
\r
### 2. IoT Sensors\r
```python\r
iot_parser = IoTJSONParser()\r
readings = iot_parser.parse_sensor_batch(sensor_data)\r
```\r
\r
### 3. API Response\r
```python\r
parser = ConstructionJSONParser()\r
result = parser.parse_string(api_response)\r
df = parser.to_dataframe(result.data)\r
```\r
\r
## Resources\r
- **DDC Book**: Chapter 2.1 - Semi-structured Data\r
Usage Guidance
This skill appears to do what it says (parse and flatten construction JSON), but before installing or running it: - Ensure the agent environment has Python and pandas available (the SKILL.md imports pandas but the skill doesn't declare that dependency). - Confirm the agent's filesystem permissions/restrictions: the skill will read files you provide, but a broad 'filesystem' permission could allow wider access—only provide explicit file paths and avoid giving system or credential files. - Note the win32 OS restriction and the required binary 'python3' may not match Windows setups (you may need to map/alias 'python3' to your Python interpreter). - There is a minor metadata/version mismatch in the manifest files (claw.json lists version 2.0.0 while registry shows 2.1.0); this is likely benign but worth verifying the source. If you need higher assurance, request a signed release or a package that declares/install dependencies (pandas) and a clear provenance for the homepage/source code.
Capability Analysis
Type: OpenClaw Skill Name: json-parser Version: 2.1.0 The skill provides JSON parsing and transformation capabilities, including reading JSON from files via the `parse_file` method in `SKILL.md`. The `claw.json` explicitly requests `filesystem` permission, which is necessary for this functionality. While file system access is aligned with the stated purpose of parsing data from files, it represents a high-risk capability. If the AI agent were to be prompted maliciously, it could potentially use this function to read arbitrary files on the system, leading to local file disclosure. However, there is no evidence of intentional malicious behavior, data exfiltration, or prompt injection attempts within the skill's code or instructions themselves.
Capability Assessment
Purpose & Capability
Name and description match the behavior in SKILL.md: parsing, validation, flattening, and conversion to DataFrames for construction/BIM/IoT JSON. Requesting python3 and filesystem access is reasonable for this task.
Instruction Scope
SKILL.md contains concrete Python code that reads files (parse_file) and expects user-provided file paths. Instructions.md explicitly tells the agent to gather input and process user-supplied files. This is within scope, but the claw.json 'filesystem' permission means the skill can access the agent filesystem—ensure policy/host limits prevent arbitrary file reads and that the agent only processes files the user authorizes.
Install Mechanism
This is an instruction-only skill (no install spec), so nothing is written to disk by the skill system. However, the provided Python code depends on pandas (imported as pd) but pandas is not declared in the skill requirements; ensure the runtime environment has pandas installed or the agent will fail when executing the code.
Credentials
The skill requests no environment variables or credentials. That is proportionate to its stated purpose. No unrelated secrets are requested.
Persistence & Privilege
always:false and normal autonomous invocation defaults are used. The skill does not request persistent or elevated privileges beyond filesystem access. Note: OS restriction is 'win32' but required binary is 'python3' which may not match common Windows python executables ('python'); this could cause runtime failures but is not a security issue by itself.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install json-parser
  3. After installation, invoke the skill by name or use /json-parser
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v2.1.0
- Added new skill documentation with detailed Python class and usage examples. - Supports parsing, validating, and flattening JSON data from construction APIs, IoT sensors, and BIM exports. - Includes BIMJSONParser and IoTJSONParser classes for specialized workflows. - Provides methods to extract elements, flatten JSON, validate schemas, and convert to DataFrames. - Quick start guides and common use case examples included in documentation.
v1.0.0
Initial release of JSON Parser skill for construction data workflows. - Parse and validate JSON from construction APIs, IoT sensors, and BIM exports - Flatten nested JSON structures into flat dictionaries - Convert JSON to pandas DataFrames for analysis - Extract elements from JSON via dot notation paths - Validate presence of required fields in JSON data - Specialized parsers for BIM metadata and IoT sensor readings included
Metadata
Slug json-parser
Version 2.1.0
License
All-time Installs 5
Active Installs 5
Total Versions 2
Frequently Asked Questions

What is Json Parser?

Parse and validate JSON data from construction APIs, IoT sensors, and BIM exports. Transform nested JSON to flat DataFrames. It is an AI Agent Skill for Claude Code / OpenClaw, with 1511 downloads so far.

How do I install Json Parser?

Run "/install json-parser" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Json Parser free?

Yes, Json Parser is completely free (open-source). You can download, install and use it at no cost.

Which platforms does Json Parser support?

Json Parser is cross-platform and runs anywhere OpenClaw / Claude Code is available (win32).

Who created Json Parser?

It is built and maintained by datadrivenconstruction (@datadrivenconstruction); the current version is v2.1.0.

💬 Comments