I want to store content and metadata for a website in a "markdown with JSON header" sort of format. Extracting the JSON header with regex seems like a Very Bad Idea. Are there any JSON parsers for PHP that will simply parse a JSON object until the closing brace of the outermost object, and then just stop? Preferably that will also give me the string offset of the end of the JSON substring.
I could require some sort of delimiter (like a blank line) between the JSON and markdown strings, but it seems like it should be unnecessary since JSON already seems to delimit itself.
I don't know if I'm using the right language to describe this problem; perhaps that's why I'm having difficulty finding anything
Here's an example just for fun:
{
"title": "example post",
"tags":["a","b","c"]
}
This is an *example*. The metadata for this post is stored inline with the data itself! How cool is that??!
- here's
- a
- list
If it helps, this only needs to work with PHP7