JsonFlow


NameJsonFlow JSON
Version 0.1.1.2 PyPI version JSON
download
home_page
Summary
upload_time2023-10-13 00:33:03
maintainer
docs_urlNone
authorBecomeAllan
requires_python
licenseMIT
keywords json dictionary manipulation traversal nested extraction configuration api data storage python jsonflow
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # JsonFlow (beta)

## Introduction
JsonFlow is a robust Python library designed by @BecomeAllan to seamlessly manipulate and traverse nested JSON data structures (and Python dictionaries). It provides intuitive functionalities for deep data extraction, modification, and inspection, making it an essential tool for developers working with complex JSON structures. Whether you're handling configuration files, API responses, data storage, AI pipelines... JsonFlow streamlines the process, giving you the power to interact with JSON like never before.

---

JsonFlow was built entirely in Python, ensuring a smooth experience without external dependencies. To install, simply use:

```
!pip install -q JsonFlow
```

---
# **JsonFlow: Powering Ecosystems of Applications and Pipelines**

The JsonFlow library is not just a tool—it's a game-changer. Crafted with precision and vision, it's designed to empower developers to create entire ecosystems of applications and pipelines, enhancing readability and facilitating seamless integration with various platforms. The drive behind this initiative is to harness the vast potential of both structured and unstructured data, ensuring that the inherent information is not just accessible, but also utilizable to its fullest.

JsonFlow is not just a library; it's a framework. It's aimed at being the cornerstone for automating tasks, whether they're rooted in data exploration or agile development. As we venture into the future, our roadmap for JsonFlow includes:

+ [ ] Developing a build in the Mojo language, bringing the velocity of C/C++ to Python.
+ [ ] Integrating with vectorized/Tensor operations from libraries such as NumPy and PyTorch. This will streamline the construction of training/inference pipelines more easily for machine learning and deep learning models, enhancing the full potential of the automation process.
+ [ ] Implementing automatic process management, ensuring the efficiency of your pipelines, and providing comprehensive logs to monitor behavior and performance.

By choosing JsonFlow, you're not just selecting a tool, but aligning with a vision for a more integrated, efficient, and data-driven future.


## Core Features

- **Pseudo Formatting**: Get a formatted, bird's-eye view of your JSON structure, making it easier to understand the nested relationships within.
- **Customizable Query Mechanism**: Use lambda functions, string paths, and more to selectively extract or modify parts of your JSON.
- **Soft & Hard Insertion**: Whether you're looking to non-destructively manipulate your data or dive deep with modifications, JsonFlow has got you covered.
- **Flatten and Structure**: Easily flatten deep JSON structures to a linear format or restructure them as per your requirements.

## Examples

Let's dive into some of the key features with example usages where:

```python
from JsonFlow import JsoniFy

some_dict = {
    "A": {
        "B": [
         {
            "C": {
                "Text": "Test text"
            },
            "D": "Value2"
        },
         {
            "C": {
                "Text": "Test text"
            },
            "D": "Value2"
        },   
        ],
        "E": {
            "Text": "Test text 2 E"
        }
    },
    "F": {
        "G": {
            "H": "Value4"
        },
        "I": 3
        }
}

data = JsoniFy(some_dict)
```


### 1. Pseudo Formatting

Using `pseudo_format()`, you can get a visual representation of your JSON structure:

```python
data.pseudo_format()

# Output:
- A
|   - B (list[dict])
|   |   - C
|   |   |   - Text (str)
|   |   - D (str)
|   - E
|   |   - Text (str)
- F
|   - G
|   |   - H (str)
|   - I (int)
```

### 2. Customizable /Query Mechanism

Retrieve or modify selective parts of your JSON:

```python
output = data({
    "A": {
        "B":[{
            "C": {"Text": lambda x: x.upper()}
        }],
        "E":True
    },
    "F": {
        "I": True
    }
})
# result
{
  "A": {
    "B": [
      {
        "C": {
          "Text": "TEST TEXT"
        }
      },
      {
        "C": {
          "Text": "TEST TEXT"
        }
      }
    ],
    "E": {
      "Text": "Test text 2 E"
    }
  },
  "F": {
    "I": 3
  }
}


# or query via path

data.query_path("A/B/C")
# result
[{'Text': 'Test text'}, {'Text': 'Test text'}]

```

### 3. Soft Insertion

Use `soft_insert()` to apply a custom function across your JSON:

```python
def custom_value_func_embed(key, value):
    if isinstance(value, dict):
      # print(value.keys())
      if 'Text' in value.keys():
          return value.update({f"Embed({value['Text']})": len(value["Text"])})
    return None

data.soft_insert(custom_value_func_embed, inplace = False)

# result
{
  "A": {
    "B": [
      {
        "C": {
          "Text": "Test text",
          "Embed(Test text)": 9
        },
        "D": "Value2"
      },
      {
        "C": {
          "Text": "Test text",
          "Embed(Test text)": 9
        },
        "D": "Value2"
      }
    ],
    "E": {
      "Text": "Test text 2 E",
      "Embed(Test text 2 E)": 13
    }
  },
  "F": {
    "G": {
      "H": "Value4"
    },
    "I": 3
  }
}
```

### 4. Hard Insertion

For specific structural modifications, leverage `hard_insert()`:

```python
from JsonFlow import deep_merge

data_test = data.hard_insert(["A/B"], deep_merge)

# Result
[
    {'A': {
        'B': {
            'C': {
                'Text': ['Test text', 'Test text']
                },
            'D': ['Value2', 'Value2']},
        'E': {'Text': 'Test text 2 E'}
        },
     'F': {
        'G': {'H': 'Value4'},
        'I': 3}}
]
```

### 5. Flattening and Structuring

Easily switch between deep and linear representations:

```python

from JsonFlow import flatten_dict

def fu(x):
  return str(x)

output = flatten_dict(data.data, func = fu)
# result
[
  {
    "path": "Doc[1]/A/B[1]/C/Text",
    "content": "Test text"
  },
  {
    "path": "Doc[1]/A/B[1]/D",
    "content": "Value2"
  },
  {
    "path": "Doc[1]/A/B[2]/C/Text",
    "content": "Test text"
  },
  {
    "path": "Doc[1]/A/B[2]/D",
    "content": "Value2"
  },
  {
    "path": "Doc[1]/A/E/Text",
    "content": "Test text 2 E"
  },
  {
    "path": "Doc[1]/F/G/H",
    "content": "Value4"
  },
  {
    "path": "Doc[1]/F/I",
    "content": "3"
  }
]
```

```python
from JsonFlow import structure_data

res = [{'path': 'A/B[1]', 'content': {"text": "hi", "age":10}},
       {'path': 'A/B[2]', 'content': {"text": "hi", "age":10}},
       {'path': 'A/B[3]', 'content': {"text": "hi2", "age":10}}]

structure_data(res, nested=True,
            adjust_list=True,
            keys_content = ["text"])

# result
{'A': {'B': [{'text': 'hi'},
   {'text': 'hi'},
   {'text': 'hi2'}]}}

structure_data(res, nested=True,
              adjust_list=False,
              keys_content = ["text"])

# result
{'A': {'B[1]': {'text': 'hi'},
  'B[2]': {'text': 'hi'},
  'B[3]': {'text': 'hi2'}}}
```

### 6. Regex


Find the relevant keys or values in your JSON:

```python

from JsonFlow import find_keys_by_regex, find_values_by_depth


some_dict = {
    "A": {
        "B": [
         {
            "1C": {
                "Text": "Test text"
            },
            "D": "Value2"
        },
         {
            "2C": {
                "Text": "Test text"
            },
            "D": "Value2"
        },   
        ],
        "E": {
            "Text": "Test text 2 E"
        }
    },
    "F": {
        "G": {
            "H": "Value4"
        },
        "I": 3
        }
}


find_keys_by_regex(some_dict, r"\d.", return_type="dict")

# {'A': {'B': {0: {'1C': {'Text': 'Test text'}},
#    1: {'2C': {'Text': 'Test text'}}}}}

find_keys_by_regex(some_dict, r"\d.", return_type="list")

# ['A/B/0/1C', 'A/B/1/2C']

find_values_by_depth(some_dict, r'Value.')

# [(['A', 'B', 0, 'D'], 'Value2'),
#  (['A', 'B', 1, 'D'], 'Value2'),
#  (['F', 'G', 'H'], 'Value4')]
```

### Utility functions (Merge)

Some additional useful features


```python

content_to_merge = [
    {"test": ["value1", "value2"],
     "adicional_info": {"label": "label_value1"}},
    {"test": "value3",
     "adicional_info": {"label": "label_value2"}},
    {"test": {"content": "valu3"},
     "adicional_info": {"label": "label_value3"}},
] 

###

merge_content(content_to_merge)

### output
{'test': [
    ['value1', 'value2'],
    'value3',
     {'content': 'valu3'}
    ],
 'adicional_info': [
    {'label': 'label_value1'},
    {'label': 'label_value2'},
    {'label': 'label_value3'}
]}

###

deep_merge(content_to_merge)

### output
{'test': [
    ['value1', 'value2'],
    'value3',
    {'content': 'valu3'}
    ],
 'adicional_info': {
    'label': [
        'label_value1',
        'label_value2',
        'label_value3'
        ]}}

```

---

### Parsers

To utilize the parsers built for JsonFlow, follow these steps:

```
!wget https://github.com/jgm/pandoc/releases/download/2.19.2/pandoc-2.19.2-1-amd64.deb -O pandoc-2.19.2-1-amd64.deb
!dpkg -i pandoc-2.19.2-1-amd64.deb

!pip install --upgrade -q pandoc==2.3 beautifulsoup4
!pip install -q JsonFlow[parse]
```

an now you have the pandoc library to integrate to any possibility of document to document, see [pandoc](https://pandoc.org/) or the library of python in [Python pandoc](https://github.com/boisgera/pandoc).


```python
import pandoc
from JsonFlow.utils import pandoc_to_dict, dict_to_html
from JsonFlow.utils import sample_html, sample_md




doc_p = pandoc.read(sample_md, format= "markdown")

pandoc_to_dict(doc_p[1])

# output
[{'path': 'Document/H1',
  'text': 'Markdown Features\n',
  'meta': "('markdown-features', [], [])"},
 {'path': 'Document/H2', 'text': 'Headers\n', 'meta': "('headers', [], [])"},
 {'path': 'Document/P',
  'text': 'You can create headers of different levels:\n'},
...
 {'path': 'Document/BulletList/Item[1]/Plain[7]',
  'text': '☒ Completed task\n'},
 {'path': 'Document/BulletList/Item[1]/Plain[8]',
  'text': '☐ Incomplete task\n'}]

####

data = [
    {'path': 'html/head/title', 'content': 'My title'},
        {'path': 'document/ul/li[1]', 'content': 'Item 1'},
        {'path': 'document/ul/li[1]/ul/li', 'content': 'Subitem 1.1'},
        {'path': 'document/ul/li[2]', 'content': 'Item 2'}]

html_trns = dict_to_html(data[0:13])

### output
# <html>
#  <head>
#   <title>
#    My title
#   </title>
#  </head>
# </html>
# <document>
#  <ul>
#   <li>
#    Item 1
#    <ul>
#     <li>
#      Subitem 1.1
#     </li>
#    </ul>
#   </li>
#   <li>
#    Item 2
#   </li>
#  </ul>
# </document>


pandoc_parse_html = pandoc.read(html_trns, format = "html")

print(pandoc.write(pandoc_parse_html, format="markdown"))

## Output

# -   Item 1
#     -   Subitem 1.1
# -   Item 2
```


---

## Contributions

Feel free to help build this ecosystem, with applications from parses to pipelines, search engines, and ML engines. This library was designed to improve AI models but can handle much more technology. Soon, we will have a repository to archive the more useful pieces of code of day life.


## Conclusion

JsonFlow is your go-to solution for anything JSON in Python. With its vast array of features and user-friendly interface, your JSON-related tasks will feel like a breeze. Dive in, explore, and let JsonFlow take your JSON game to the next level.


---

**Disclaimer**: While every effort has been made to ensure the accuracy and reliability of the JsonFlow library, the author and contributors cannot guarantee that it is free from defects. Users are advised to ensure that the library meets their requirements before integrating it into their projects. The author disclaims all warranties, either express or implied, including but not limited to any implied warranties of merchantability or fitness for a particular purpose. In no event shall the author be liable for any damages, including but not limited to special, direct, indirect, or consequential damages, losses, or expenses arising in connection with this library or its use.

Furthermore, I am a member of the academic community, and I would be immensely flattered if you could cite this work when utilizing JsonFlow in your projects or publications.

[![DOI](https://zenodo.org/badge/703299059.svg)](https://zenodo.org/badge/latestdoi/703299059)

---

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "JsonFlow",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "json,dictionary,manipulation,traversal,nested,extraction,configuration,API,data storage,python,JsonFlow",
    "author": "BecomeAllan",
    "author_email": "becomeallan@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f5/11/b73a6d3e056b53194fe8dc71c310df00cc9fb524d4cb1ab72d6de4b4cbe4/JsonFlow-0.1.1.2.tar.gz",
    "platform": null,
    "description": "# JsonFlow (beta)\n\n## Introduction\nJsonFlow is a robust Python library designed by @BecomeAllan to seamlessly manipulate and traverse nested JSON data structures (and Python dictionaries). It provides intuitive functionalities for deep data extraction, modification, and inspection, making it an essential tool for developers working with complex JSON structures. Whether you're handling configuration files, API responses, data storage, AI pipelines... JsonFlow streamlines the process, giving you the power to interact with JSON like never before.\n\n---\n\nJsonFlow was built entirely in Python, ensuring a smooth experience without external dependencies. To install, simply use:\n\n```\n!pip install -q JsonFlow\n```\n\n---\n# **JsonFlow: Powering Ecosystems of Applications and Pipelines**\n\nThe JsonFlow library is not just a tool\u2014it's a game-changer. Crafted with precision and vision, it's designed to empower developers to create entire ecosystems of applications and pipelines, enhancing readability and facilitating seamless integration with various platforms. The drive behind this initiative is to harness the vast potential of both structured and unstructured data, ensuring that the inherent information is not just accessible, but also utilizable to its fullest.\n\nJsonFlow is not just a library; it's a framework. It's aimed at being the cornerstone for automating tasks, whether they're rooted in data exploration or agile development. As we venture into the future, our roadmap for JsonFlow includes:\n\n+ [ ] Developing a build in the Mojo language, bringing the velocity of C/C++ to Python.\n+ [ ] Integrating with vectorized/Tensor operations from libraries such as NumPy and PyTorch. This will streamline the construction of training/inference pipelines more easily for machine learning and deep learning models, enhancing the full potential of the automation process.\n+ [ ] Implementing automatic process management, ensuring the efficiency of your pipelines, and providing comprehensive logs to monitor behavior and performance.\n\nBy choosing JsonFlow, you're not just selecting a tool, but aligning with a vision for a more integrated, efficient, and data-driven future.\n\n\n## Core Features\n\n- **Pseudo Formatting**: Get a formatted, bird's-eye view of your JSON structure, making it easier to understand the nested relationships within.\n- **Customizable Query Mechanism**: Use lambda functions, string paths, and more to selectively extract or modify parts of your JSON.\n- **Soft & Hard Insertion**: Whether you're looking to non-destructively manipulate your data or dive deep with modifications, JsonFlow has got you covered.\n- **Flatten and Structure**: Easily flatten deep JSON structures to a linear format or restructure them as per your requirements.\n\n## Examples\n\nLet's dive into some of the key features with example usages where:\n\n```python\nfrom JsonFlow import JsoniFy\n\nsome_dict = {\n    \"A\": {\n        \"B\": [\n         {\n            \"C\": {\n                \"Text\": \"Test text\"\n            },\n            \"D\": \"Value2\"\n        },\n         {\n            \"C\": {\n                \"Text\": \"Test text\"\n            },\n            \"D\": \"Value2\"\n        },   \n        ],\n        \"E\": {\n            \"Text\": \"Test text 2 E\"\n        }\n    },\n    \"F\": {\n        \"G\": {\n            \"H\": \"Value4\"\n        },\n        \"I\": 3\n        }\n}\n\ndata = JsoniFy(some_dict)\n```\n\n\n### 1. Pseudo Formatting\n\nUsing `pseudo_format()`, you can get a visual representation of your JSON structure:\n\n```python\ndata.pseudo_format()\n\n# Output:\n- A\n|   - B (list[dict])\n|   |   - C\n|   |   |   - Text (str)\n|   |   - D (str)\n|   - E\n|   |   - Text (str)\n- F\n|   - G\n|   |   - H (str)\n|   - I (int)\n```\n\n### 2. Customizable /Query Mechanism\n\nRetrieve or modify selective parts of your JSON:\n\n```python\noutput = data({\n    \"A\": {\n        \"B\":[{\n            \"C\": {\"Text\": lambda x: x.upper()}\n        }],\n        \"E\":True\n    },\n    \"F\": {\n        \"I\": True\n    }\n})\n# result\n{\n  \"A\": {\n    \"B\": [\n      {\n        \"C\": {\n          \"Text\": \"TEST TEXT\"\n        }\n      },\n      {\n        \"C\": {\n          \"Text\": \"TEST TEXT\"\n        }\n      }\n    ],\n    \"E\": {\n      \"Text\": \"Test text 2 E\"\n    }\n  },\n  \"F\": {\n    \"I\": 3\n  }\n}\n\n\n# or query via path\n\ndata.query_path(\"A/B/C\")\n# result\n[{'Text': 'Test text'}, {'Text': 'Test text'}]\n\n```\n\n### 3. Soft Insertion\n\nUse `soft_insert()` to apply a custom function across your JSON:\n\n```python\ndef custom_value_func_embed(key, value):\n    if isinstance(value, dict):\n      # print(value.keys())\n      if 'Text' in value.keys():\n          return value.update({f\"Embed({value['Text']})\": len(value[\"Text\"])})\n    return None\n\ndata.soft_insert(custom_value_func_embed, inplace = False)\n\n# result\n{\n  \"A\": {\n    \"B\": [\n      {\n        \"C\": {\n          \"Text\": \"Test text\",\n          \"Embed(Test text)\": 9\n        },\n        \"D\": \"Value2\"\n      },\n      {\n        \"C\": {\n          \"Text\": \"Test text\",\n          \"Embed(Test text)\": 9\n        },\n        \"D\": \"Value2\"\n      }\n    ],\n    \"E\": {\n      \"Text\": \"Test text 2 E\",\n      \"Embed(Test text 2 E)\": 13\n    }\n  },\n  \"F\": {\n    \"G\": {\n      \"H\": \"Value4\"\n    },\n    \"I\": 3\n  }\n}\n```\n\n### 4. Hard Insertion\n\nFor specific structural modifications, leverage `hard_insert()`:\n\n```python\nfrom JsonFlow import deep_merge\n\ndata_test = data.hard_insert([\"A/B\"], deep_merge)\n\n# Result\n[\n    {'A': {\n        'B': {\n            'C': {\n                'Text': ['Test text', 'Test text']\n                },\n            'D': ['Value2', 'Value2']},\n        'E': {'Text': 'Test text 2 E'}\n        },\n     'F': {\n        'G': {'H': 'Value4'},\n        'I': 3}}\n]\n```\n\n### 5. Flattening and Structuring\n\nEasily switch between deep and linear representations:\n\n```python\n\nfrom JsonFlow import flatten_dict\n\ndef fu(x):\n  return str(x)\n\noutput = flatten_dict(data.data, func = fu)\n# result\n[\n  {\n    \"path\": \"Doc[1]/A/B[1]/C/Text\",\n    \"content\": \"Test text\"\n  },\n  {\n    \"path\": \"Doc[1]/A/B[1]/D\",\n    \"content\": \"Value2\"\n  },\n  {\n    \"path\": \"Doc[1]/A/B[2]/C/Text\",\n    \"content\": \"Test text\"\n  },\n  {\n    \"path\": \"Doc[1]/A/B[2]/D\",\n    \"content\": \"Value2\"\n  },\n  {\n    \"path\": \"Doc[1]/A/E/Text\",\n    \"content\": \"Test text 2 E\"\n  },\n  {\n    \"path\": \"Doc[1]/F/G/H\",\n    \"content\": \"Value4\"\n  },\n  {\n    \"path\": \"Doc[1]/F/I\",\n    \"content\": \"3\"\n  }\n]\n```\n\n```python\nfrom JsonFlow import structure_data\n\nres = [{'path': 'A/B[1]', 'content': {\"text\": \"hi\", \"age\":10}},\n       {'path': 'A/B[2]', 'content': {\"text\": \"hi\", \"age\":10}},\n       {'path': 'A/B[3]', 'content': {\"text\": \"hi2\", \"age\":10}}]\n\nstructure_data(res, nested=True,\n            adjust_list=True,\n            keys_content = [\"text\"])\n\n# result\n{'A': {'B': [{'text': 'hi'},\n   {'text': 'hi'},\n   {'text': 'hi2'}]}}\n\nstructure_data(res, nested=True,\n              adjust_list=False,\n              keys_content = [\"text\"])\n\n# result\n{'A': {'B[1]': {'text': 'hi'},\n  'B[2]': {'text': 'hi'},\n  'B[3]': {'text': 'hi2'}}}\n```\n\n### 6. Regex\n\n\nFind the relevant keys or values in your JSON:\n\n```python\n\nfrom JsonFlow import find_keys_by_regex, find_values_by_depth\n\n\nsome_dict = {\n    \"A\": {\n        \"B\": [\n         {\n            \"1C\": {\n                \"Text\": \"Test text\"\n            },\n            \"D\": \"Value2\"\n        },\n         {\n            \"2C\": {\n                \"Text\": \"Test text\"\n            },\n            \"D\": \"Value2\"\n        },   \n        ],\n        \"E\": {\n            \"Text\": \"Test text 2 E\"\n        }\n    },\n    \"F\": {\n        \"G\": {\n            \"H\": \"Value4\"\n        },\n        \"I\": 3\n        }\n}\n\n\nfind_keys_by_regex(some_dict, r\"\\d.\", return_type=\"dict\")\n\n# {'A': {'B': {0: {'1C': {'Text': 'Test text'}},\n#    1: {'2C': {'Text': 'Test text'}}}}}\n\nfind_keys_by_regex(some_dict, r\"\\d.\", return_type=\"list\")\n\n# ['A/B/0/1C', 'A/B/1/2C']\n\nfind_values_by_depth(some_dict, r'Value.')\n\n# [(['A', 'B', 0, 'D'], 'Value2'),\n#  (['A', 'B', 1, 'D'], 'Value2'),\n#  (['F', 'G', 'H'], 'Value4')]\n```\n\n### Utility functions (Merge)\n\nSome additional useful features\n\n\n```python\n\ncontent_to_merge = [\n    {\"test\": [\"value1\", \"value2\"],\n     \"adicional_info\": {\"label\": \"label_value1\"}},\n    {\"test\": \"value3\",\n     \"adicional_info\": {\"label\": \"label_value2\"}},\n    {\"test\": {\"content\": \"valu3\"},\n     \"adicional_info\": {\"label\": \"label_value3\"}},\n] \n\n###\n\nmerge_content(content_to_merge)\n\n### output\n{'test': [\n    ['value1', 'value2'],\n    'value3',\n     {'content': 'valu3'}\n    ],\n 'adicional_info': [\n    {'label': 'label_value1'},\n    {'label': 'label_value2'},\n    {'label': 'label_value3'}\n]}\n\n###\n\ndeep_merge(content_to_merge)\n\n### output\n{'test': [\n    ['value1', 'value2'],\n    'value3',\n    {'content': 'valu3'}\n    ],\n 'adicional_info': {\n    'label': [\n        'label_value1',\n        'label_value2',\n        'label_value3'\n        ]}}\n\n```\n\n---\n\n### Parsers\n\nTo utilize the parsers built for JsonFlow, follow these steps:\n\n```\n!wget https://github.com/jgm/pandoc/releases/download/2.19.2/pandoc-2.19.2-1-amd64.deb -O pandoc-2.19.2-1-amd64.deb\n!dpkg -i pandoc-2.19.2-1-amd64.deb\n\n!pip install --upgrade -q pandoc==2.3 beautifulsoup4\n!pip install -q JsonFlow[parse]\n```\n\nan now you have the pandoc library to integrate to any possibility of document to document, see [pandoc](https://pandoc.org/) or the library of python in [Python pandoc](https://github.com/boisgera/pandoc).\n\n\n```python\nimport pandoc\nfrom JsonFlow.utils import pandoc_to_dict, dict_to_html\nfrom JsonFlow.utils import sample_html, sample_md\n\n\n\n\ndoc_p = pandoc.read(sample_md, format= \"markdown\")\n\npandoc_to_dict(doc_p[1])\n\n# output\n[{'path': 'Document/H1',\n  'text': 'Markdown Features\\n',\n  'meta': \"('markdown-features', [], [])\"},\n {'path': 'Document/H2', 'text': 'Headers\\n', 'meta': \"('headers', [], [])\"},\n {'path': 'Document/P',\n  'text': 'You can create headers of different levels:\\n'},\n...\n {'path': 'Document/BulletList/Item[1]/Plain[7]',\n  'text': '\u2612 Completed task\\n'},\n {'path': 'Document/BulletList/Item[1]/Plain[8]',\n  'text': '\u2610 Incomplete task\\n'}]\n\n####\n\ndata = [\n    {'path': 'html/head/title', 'content': 'My title'},\n        {'path': 'document/ul/li[1]', 'content': 'Item 1'},\n        {'path': 'document/ul/li[1]/ul/li', 'content': 'Subitem 1.1'},\n        {'path': 'document/ul/li[2]', 'content': 'Item 2'}]\n\nhtml_trns = dict_to_html(data[0:13])\n\n### output\n# <html>\n#  <head>\n#   <title>\n#    My title\n#   </title>\n#  </head>\n# </html>\n# <document>\n#  <ul>\n#   <li>\n#    Item 1\n#    <ul>\n#     <li>\n#      Subitem 1.1\n#     </li>\n#    </ul>\n#   </li>\n#   <li>\n#    Item 2\n#   </li>\n#  </ul>\n# </document>\n\n\npandoc_parse_html = pandoc.read(html_trns, format = \"html\")\n\nprint(pandoc.write(pandoc_parse_html, format=\"markdown\"))\n\n## Output\n\n# -   Item 1\n#     -   Subitem 1.1\n# -   Item 2\n```\n\n\n---\n\n## Contributions\n\nFeel free to help build this ecosystem, with applications from parses to pipelines, search engines, and ML engines. This library was designed to improve AI models but can handle much more technology. Soon, we will have a repository to archive the more useful pieces of code of day life.\n\n\n## Conclusion\n\nJsonFlow is your go-to solution for anything JSON in Python. With its vast array of features and user-friendly interface, your JSON-related tasks will feel like a breeze. Dive in, explore, and let JsonFlow take your JSON game to the next level.\n\n\n---\n\n**Disclaimer**: While every effort has been made to ensure the accuracy and reliability of the JsonFlow library, the author and contributors cannot guarantee that it is free from defects. Users are advised to ensure that the library meets their requirements before integrating it into their projects. The author disclaims all warranties, either express or implied, including but not limited to any implied warranties of merchantability or fitness for a particular purpose. In no event shall the author be liable for any damages, including but not limited to special, direct, indirect, or consequential damages, losses, or expenses arising in connection with this library or its use.\n\nFurthermore, I am a member of the academic community, and I would be immensely flattered if you could cite this work when utilizing JsonFlow in your projects or publications.\n\n[![DOI](https://zenodo.org/badge/703299059.svg)](https://zenodo.org/badge/latestdoi/703299059)\n\n---\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "",
    "version": "0.1.1.2",
    "project_urls": null,
    "split_keywords": [
        "json",
        "dictionary",
        "manipulation",
        "traversal",
        "nested",
        "extraction",
        "configuration",
        "api",
        "data storage",
        "python",
        "jsonflow"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2a4bb4a213bda9c4c3505db5081aeb075555c526eceea6e0adcb7968cb08366e",
                "md5": "0bd1d1cabf312b0adcffb9fd988a736d",
                "sha256": "cd94f4624f146c7614c0427fb35534c77a06b633b9ef4cddfcd1c9340bb76dce"
            },
            "downloads": -1,
            "filename": "JsonFlow-0.1.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0bd1d1cabf312b0adcffb9fd988a736d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 21568,
            "upload_time": "2023-10-13T00:33:01",
            "upload_time_iso_8601": "2023-10-13T00:33:01.164037Z",
            "url": "https://files.pythonhosted.org/packages/2a/4b/b4a213bda9c4c3505db5081aeb075555c526eceea6e0adcb7968cb08366e/JsonFlow-0.1.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f511b73a6d3e056b53194fe8dc71c310df00cc9fb524d4cb1ab72d6de4b4cbe4",
                "md5": "356e3046e89c556f04ff3bac7bc770b4",
                "sha256": "c07c98aeceec972810230cd1164c190b6c114ea64e936a10dcf7290489644309"
            },
            "downloads": -1,
            "filename": "JsonFlow-0.1.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "356e3046e89c556f04ff3bac7bc770b4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 23741,
            "upload_time": "2023-10-13T00:33:03",
            "upload_time_iso_8601": "2023-10-13T00:33:03.865359Z",
            "url": "https://files.pythonhosted.org/packages/f5/11/b73a6d3e056b53194fe8dc71c310df00cc9fb524d4cb1ab72d6de4b4cbe4/JsonFlow-0.1.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-13 00:33:03",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "jsonflow"
}
        
Elapsed time: 0.12378s