JSON-to-Dict Model

Overview

The JSON-to-Dict Model is designed to transform JSON data into structured dictionary-like representations. This model is useful for converting JSON objects into more readable formats or extracting specific parameter details in a consistent format.

Task Description

Given a JSON object, the model outputs a dictionary where:

  • Keys represent various attributes of the JSON object.
  • Data Types specify the type of each attribute.
  • Descriptions provide a clear explanation of each attribute's meaning.

Code to run

Example Input and Output

Input JSON

{
  "id": 252,
  "name": "User 10",
  "email": "user6@example.com",
  "address": {
    "street": "954 Main St",
    "city": "City 13",
    "state": "State",
    "zip": "41664"
  },
  "phoneNumbers": [
    {
      "type": "home",
      "number": "767-555-9849"
    },
    {
      "type": "work",
      "number": "901-555-7829"
    }
  ],
  "isActive": false,
  "preferences": {
    "contactMethod": "email",
    "newsletterSubscribed": true
  },
  "orders": [
    {
      "orderId": "e2c36f29-fc54-4ad5-af6a-8cad97551887",
      "amount": 275.84669959794803
    },
    {
      "orderId": "1d091458-49dc-4de9-9699-a784f8a5f685",
      "amount": 458.594914191431
    }
  ]
}

Output Dictionary

[
    {"key": "id", "data_type": "Integer", "description": "ID of the user."},
    {"key": "name", "data_type": "String", "description": "Full name of the user."},
    {"key": "email", "data_type": "String", "description": "Email address of the user."},
    {"key": "address", "data_type": "Object", "description": "Address of the user."},
    {"key": "address.street", "data_type": "String", "description": "Street address of the user."},
    {"key": "address.city", "data_type": "String", "description": "City of the user's address."},
    {"key": "address.state", "data_type": "String", "description": "State of the user's address."},
    {"key": "address.zip", "data_type": "String", "description": "ZIP code of the user's address."},
    {"key": "phoneNumbers", "data_type": "Array", "description": "List of phone numbers."},
    {"key": "phoneNumbers[].type", "data_type": "String", "description": "Type of phone number (e.g., home, work)."},
    {"key": "phoneNumbers[].number", "data_type": "String", "description": "Phone number."},
    {"key": "isActive", "data_type": "Boolean", "description": "User's active status."},
    {"key": "preferences", "data_type": "Object", "description": "User's preferences."},
    {"key": "preferences.contactMethod", "data_type": "String", "description": "Preferred contact method."},
    {"key": "preferences.newsletterSubscribed", "data_type": "Boolean", "description": "Newsletter subscription status."},
    {"key": "orders", "data_type": "Array", "description": "List of orders."},
    {"key": "orders[].orderId", "data_type": "String", "description": "Order ID."},
    {"key": "orders[].amount", "data_type": "Float", "description": "Order amount."}
]

Model Capabilities

  • JSON Parsing: Converts JSON objects into a structured dictionary.
  • Customizable Output: Tailor the output format to match specific needs.
  • Versatile Usage: Suitable for various applications where structured data representation is needed.

How to Use

  • Load the Model: Use the transformers library to load the model.
  • Input Data: Provide a JSON object as input.
  • Generate Output: Obtain the dictionary format output.
Downloads last month
3
Safetensors
Model size
60.5M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train jayvinay/json-to-dictionary-model