I am using Claude to generate some content.
I specified the output format as strictly JSON with the format.
Overall it respects very well the format
{
"Activity": [
{
"Title_activity": "",
"Description_activity": ""
}
]
}
The only problem is often it had some copy before my code like:
HERE IS THE CODE / generation / jsonformat etc....
{
"Activity": [
{
"Title_activity": "",
"Description_activity": ""
}
]
}
To parse it properly I want to either remove anything before {"Activity": [
or select all the text from {"Activity": [
to the end.
I tried the lastest, and I use the following regex: \{[\s\S]*?"Activity": \[(.*\n)+}
validated with regex101.com but I have this output:
{
"Title_activity": "Chasse",
"Description_activity": "Transformez"
},
{
"Title_activity": "RĂ©cit ",
"Description_activity": "Racontez"
},
{
"Title_activity": "Photographie",
"Description_activity": "Utilisez votre téléphone"
},
{
"Title_activity": "Souterrain",
"Description_activity": "Amusez-vous"
}
]
which is incorrect as it is missing the beginning of my code:
{
"Activity": [
And the }
at the end
I am not sure how to approach this, it is a very long text to extract and the text before the JSON is random
I’ve attached the blueprint, data is passed in scenario input
many thanks
blueprint.json (6.0 KB)