Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Parse and validate JSON data from construction APIs, IoT sensors, and BIM exports. Transform nested JSON to flat DataFrames.
.claude/skills/datadrivenconstruction-json-parser/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 40% | 0% |
| case-01 | ✗→✓ | ▲ Improved | 88% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 52% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 70% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 139% | 0% |
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.
pythonimport 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 = {} for key, value in data.items(): new_key = f"{prefix}_{key}" if prefix else key if isinstance(value, dict): flat.update(self.flatten_json(value, new_key)) elif isinstance(value, list): if all(isinstance(i, (str, int, float, bool, type(None))) for i in value): flat[new_key] = value else: for i, item in enumerate(value): if isinstance(item, dict): flat.update(self.flatten_json(item, f"{new_key}_{i}")) else: flat[f"{new_key}_{i}"] = item else: flat[new_key] = value return flat def to_dataframe(self, data: Union[List[Dict], Dict]) -> pd.DataFrame: """Convert JSON data to DataFrame.""" if isinstance(data, list): flat_records = [self.flatten_json(r) if isinstance(r, dict) else {'value': r} for r in data] return pd.DataFrame(flat_records) elif isinstance(data, dict): if all(isinstance(v, list) for v in data.values()): # Dict of lists - columnar format return pd.DataFrame(data) else: flat = self.flatten_json(data) return pd.DataFrame([flat]) return pd.DataFrame() def extract_elements(self, data: Dict, path: str) -> List[Any]: """Extract elements using dot notation path.""" parts = path.split('.') current = data for part in parts: if isinstance(current, dict) and part in current: current = current[part] elif isinstance(current, list) and part.isdigit(): current = current[int(part)] else: return [] return current if isinstance(current, list) else [current] def validate_schema(self, data: Dict, required_fields: List[str]) -> Dict[str, Any]: """Validate JSON against required fields.""" flat = self.flatten_json(data) missing = [f for f in required_fields if f not in flat] present = [f for f in required_fields if f in flat] return { 'valid': len(missing) == 0, 'missing_fields': missing, 'present_fields': present, 'completeness': len(present) / len(required_fields) * 100 } # BIM JSON Parser class BIMJSONParser(ConstructionJSONParser): """Specialized parser for BIM JSON exports.""" def parse_bim_elements(self, data: Dict) -> pd.DataFrame: """Parse BIM elements from JSON export.""" elements = [] # Common BIM JSON structures if 'elements' in data: elements = data['elements'] elif 'objects' in data: elements = data['objects'] elif 'entities' in data: elements = data['entities'] elif isinstance(data, list): elements = data if not elements: return pd.DataFrame() # Flatten each element flat_elements = [] for elem in elements: if isinstance(elem, dict): flat = self.flatten_json(elem) flat_elements.append(flat) return pd.DataFrame(flat_elements) def extract_properties(self, element: Dict) -> Dict[str, Any]: """Extract properties from BIM element.""" props = {} # Common property locations in BIM JSON for key in ['properties', 'params', 'parameters', 'attributes']: if key in element and isinstance(element[key], dict): props.update(element[key]) return props # IoT JSON Parser class IoTJSONParser(ConstructionJSONParser): """Parser for IoT sensor data.""" def parse_sensor_reading(self, data: Dict) -> Dict[str, Any]: """Parse single sensor reading.""" return { 'sensor_id': data.get('sensor_id') or data.get('id'), 'timestamp': data.get('timestamp') or data.get('time'), 'value': data.get('value') or data.get('reading'), 'unit': data.get('unit', ''), 'location': data.get('location', '') } def parse_sensor_batch(self, data: List[Dict]) -> pd.DataFrame: """Parse batch of sensor readings.""" readings = [self.parse_sensor_reading(r) for r in data] return pd.DataFrame(readings)
pythonparser = ConstructionJSONParser() # Parse from file result = parser.parse_file("bim_export.json") if result.success: df = parser.to_dataframe(result.data) print(f"Loaded {len(df)} records") # Flatten nested JSON flat = parser.flatten_json(result.data) # Extract specific path elements = parser.extract_elements(result.data, "project.building.floors")
pythonbim_parser = BIMJSONParser() result = bim_parser.parse_file("revit_export.json") elements = bim_parser.parse_bim_elements(result.data)
pythoniot_parser = IoTJSONParser() readings = iot_parser.parse_sensor_batch(sensor_data)
pythonparser = ConstructionJSONParser() result = parser.parse_string(api_response) df = parser.to_dataframe(result.data)
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-21 | pass→pass | 8,254 | 7,572 | -8% | 1 | 1 | 0% | 1,634 | 3,388 | +107% | 0 | 0 | — |
case-02 | fail→pass | 13,913 | 9,051 | -35% | 1 | 1 | 0% | 2,732 | 3,819 | +40% | 0 | 0 | — |
case-03 | fail→fail | 11,436 | 13,367 | +17% | 1 | 1 | 0% | 2,063 | 4,580 | +122% | 0 | 0 | — |
case-01 | fail→pass | 10,592 | 11,967 | +13% | 1 | 1 | 0% | 2,113 | 3,983 | +88% | 0 | 0 | — |
case-04 | fail→fail | 11,422 | 6,852 | -40% | 1 | 1 | 0% | 2,190 | 3,246 | +48% | 0 | 0 | — |
case-05 | fail→fail | 14,690 | 10,118 | -31% | 1 | 1 | 0% | 2,901 | 3,919 | +35% | 0 | 0 | — |
case-06 | fail→pass | 9,804 | 3,177 | -68% | 1 | 1 | 0% | 1,706 | 2,589 | +52% | 0 | 0 | — |
case-07 | fail→pass | 7,647 | 3,597 | -53% | 1 | 1 | 0% | 1,508 | 2,562 | +70% | 0 | 0 | — |
case-20 | pass→pass | 15,655 | 10,629 | -32% | 1 | 1 | 0% | 3,278 | 3,984 | +22% | 0 | 0 | — |
case-08 | fail→pass | 7,902 | 8,801 | +11% | 1 | 1 | 0% | 1,528 | 3,651 | +139% | 0 | 0 | — |
case-09 | fail→pass | 12,269 | 3,634 | -70% | 1 | 1 | 0% | 2,385 | 2,648 | +11% | 0 | 0 | — |
case-10 | fail→pass | 9,962 | 3,978 | -60% | 1 | 1 | 0% | 1,809 | 2,661 | +47% | 0 | 0 | — |
case-11 | fail→fail | 9,146 | 4,077 | -55% | 1 | 1 | 0% | 1,781 | 2,730 | +53% | 0 | 0 | — |
case-12 | fail→pass | 13,976 | 4,292 | -69% | 1 | 1 | 0% | 2,248 | 2,675 | +19% | 0 | 0 | — |
case-13 | pass→pass | 13,954 | 4,429 | -68% | 1 | 1 | 0% | 2,087 | 2,695 | +29% | 0 | 0 | — |
case-14 | pass→pass | 5,544 | 3,051 | -45% | 1 | 1 | 0% | 920 | 2,465 | +168% | 0 | 0 | — |
case-15 | pass→pass | 6,787 | 1,890 | -72% | 1 | 1 | 0% | 1,039 | 2,255 | +117% | 0 | 0 | — |
case-16 | fail→pass | 14,407 | 7,771 | -46% | 1 | 1 | 0% | 2,570 | 3,485 | +36% | 0 | 0 | — |
case-17 | fail→pass | 13,029 | 8,204 | -37% | 1 | 1 | 0% | 2,104 | 3,463 | +65% | 0 | 0 | — |
case-18 | fail→pass | 7,541 | 2,334 | -69% | 1 | 1 | 0% | 1,219 | 2,280 | +87% | 0 | 0 | — |
case-19 | fail→pass | 10,864 | 8,666 | -20% | 1 | 1 | 0% | 1,857 | 3,480 | +87% | 0 | 0 | — |
case-22 | pass→pass | 10,269 | 10,979 | +7% | 1 | 1 | 0% | 1,962 | 4,080 | +108% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +55 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.