Current version: 1.05
My answer: why not?
Just download single file, import module at your's python file and then you can use functions: dumps, parse, parse_string, parse_with_count and parse_string_with_count.
If Pylance is arguing then just turn it off 🤷♂️ (I think i fixed it 😒)
(P.S. it is recommended to use this script only on Python version 3.14, because the script was not checked on versions below, and the static type checker will not work correctly.)
"./test_file.json"
{
"person1": {
"name": "Mike",
"age": 24,
"confidential data": {
"address": "Some Street 18",
"phone number": "+1-212-456-7890"
}
}
}./main.py
import JbobParser as jbp
# Parsing with some file (parser doesn't looks at extension of the file)
parsed_json = jbp.parse("./test_file.json")
print(parsed_json) # Outputs: {"person1": {"name": "Mike", "age": 24, "confidential data": {"address": "Some Street 18", "phone number": "+1-212-456-7890"}}}
parsed_json2, fields_count2 = jbp.parse_string_with_count("""
{
"person1": {
"name": "Mike",
"age": 24,
"confidential data": {
"address": "Some Street 18",
"phone number": "+1-212-456-7890"
}
}
}
""")
print(parsed_json2) # will output the same result
print(fields_count2) # will output count of all fields in "parsed_json2"
# dumps function used for compressing JsonBlock object into string with provided indent
print(jbp.dumps(parsed_json))
# You can assign some values to parsed json like dict object
parsed_json["person1"]["age"] = "25"
print(parsed_json) # will output same result but the age will be now string with value "25"
# like in dict object the JsonBlock provides items, keys and values functions
print(parsed_json.items()) # Outputs: [("person1", {"name": "Mike", "age": "25", ...})]
print(parsed_json.keys()) # Outputs: ["person1"]
print(parsed_json.values()) # Outputs: [{"name": "Mike", "age": "25", ...}]- Initial release
- JBobParser has switched to Python 3.14
- Reworked type system
- Added functions parse_with_count and parse_string_with_count
- Fixed StringNode
- Fixed tokenization of escape characters in string
- Added NaN, Infinity, -Infinity and null support
- Changed clamp function declaration
- You can now assign values to ArrayNode
- And other
- Position of tokens scans incorrectly
