# Json Data Extraction

> Extract, parse, and query JSON data from large enterprise files efficiently

- **Type:** Skill
- **Install:** `agentstack add skill-cxcscmu-skilllearnbench-json-data-extraction`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [cxcscmu](https://agentstack.voostack.com/s/cxcscmu)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [cxcscmu](https://github.com/cxcscmu)
- **Source:** https://github.com/cxcscmu/SkillLearnBench/tree/main/skills/b1-one-shot-claude-haiku-4-5/enterprise-information-search/json-data-extraction
- **Website:** https://cxcscmu.github.io/SkillLearnBench

## Install

```sh
agentstack add skill-cxcscmu-skilllearnbench-json-data-extraction
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# JSON Data Extraction from Enterprise Data

## Overview
This skill covers parsing and extracting information from large JSON files containing enterprise data like employee records, Slack messages, and product metadata.

## Use Cases
- Extracting specific fields from employee databases
- Searching through Slack message histories for mentions or keywords
- Finding relationships between employees and documents/reports
- Aggregating data across multiple JSON sources

## Installation & Setup
```bash
# Python has built-in json module, no installation needed
python3 -c "import json; print('JSON module available')"
```

## Code Examples

### Basic JSON Loading
```python
import json

with open('/root/DATA/metadata/employee.json', 'r') as f:
    employee_data = json.load(f)

# Access specific employee
employee = employee_data.get('eid_1e9356f5', {})
```

### Extracting Data with Filters
```python
import json

with open('/root/DATA/products/ContentForce.json', 'r') as f:
    product_data = json.load(f)

# Extract Slack messages mentioning specific employee
messages = product_data.get('slack', [])
for msg in messages:
    if 'Market Research Report' in msg.get('Message', {}).get('text', ''):
        print(msg)
```

### Extracting IDs from Text
```python
import re

def extract_employee_ids(text):
    """Extract employee IDs (format: eid_xxxxxxxx) from text"""
    pattern = r'eid_[a-f0-9]{8}'
    return re.findall(pattern, text)

# Usage
text = "@eid_1e9356f5 created this channel. @eid_06cddbb3 joined."
ids = extract_employee_ids(text)  # Returns ['eid_1e9356f5', 'eid_06cddbb3']
```

### Finding Report Authors and Reviewers
```python
import json
import re

def find_report_authors_and_reviewers(product_json_path, report_name):
    """Find employees who authored/reviewed a report"""
    with open(product_json_path, 'r') as f:
        data = json.load(f)

    authors = set()
    reviewers = set()

    messages = data.get('slack', [])
    for msg in messages:
        text = msg.get('Message', {}).get('text', '')
        if report_name.lower() in text.lower():
            # Author: person sharing the report
            author_id = msg.get('Message', {}).get('User', {}).get('userId')
            if author_id and author_id.startswith('eid_'):
                authors.add(author_id)

            # Reviewers: people responding in thread
            for reply in msg.get('ThreadReplies', []):
                reviewer_id = reply.get('User', {}).get('userId')
                if reviewer_id and reviewer_id.startswith('eid_'):
                    reviewers.add(reviewer_id)

    return list(authors), list(reviewers)
```

## Best Practices
1. **Memory Efficiency**: For large files, process in chunks rather than loading entire file
2. **Error Handling**: Always check if keys exist before accessing nested values
3. **ID Pattern Matching**: Employee IDs follow format `eid_` followed by 8 hex characters
4. **Text Search**: Use case-insensitive matching for report/document names
5. **Deduplication**: Use sets to avoid duplicate IDs before converting to lists

## Common Patterns

### Pattern 1: Search for Document Mentions
Look for link syntax in Slack: ``

### Pattern 2: Extract User IDs from Messages
- Author: `Message.User.userId`
- Reviewers: `Message.ThreadReplies[].User.userId`
- Mentions: Look for `@eid_` patterns in message text

### Pattern 3: Cross-Reference Data
Load employee.json to map IDs to names if needed for verification

## Token Tracking
When using this with APIs, track token consumption:
```python
# After API calls
tokens_used = response.usage.input_tokens + response.usage.output_tokens
```

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [cxcscmu](https://github.com/cxcscmu)
- **Source:** [cxcscmu/SkillLearnBench](https://github.com/cxcscmu/SkillLearnBench)
- **License:** MIT
- **Homepage:** https://cxcscmu.github.io/SkillLearnBench

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** yes
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-cxcscmu-skilllearnbench-json-data-extraction
- Seller: https://agentstack.voostack.com/s/cxcscmu
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
