I am currently using OpenAI to send back a template for training via a json format. However, it’s well known that using the assistant api doesn’t actually send back the json in a readable format on the first go, I believe it captures the full response as “context”. Anyways, once generated, I take this json in the response and save it as a text data type in my bubble app.
I am desperately trying to display different parts of this json in a clean way but am running into issues with each approach.
- Regex - This is just not clean and the complexity of nesting doesn’t allow for regex to be a viable option.
- Using a json parser plugin like JSON Machine to display the information needed. However, once it gets to a nested section, then it doesn’t display anything but “[object], [object]”
- Running a backend workflow on a list. I tried setting up a BE WF to take the original “context” that I’m saving in my database as text, running that through an internal api to parse the json, but having difficult saving the data correctly now. I think this is the best option, but also most likely the most costly when scaled.
Here’s an example JSON response where I struggle to successfully save the Weekly routines and drills under the correct sections.
{
“golfer_details”: {
“name”: “Tiger Woods”,
“age”: 35,
“gender”: “Male”,
“skill_level”: “Expert”,
“strength”: “striking approach shots with 56, 52 and pitching wedge”,
“weakness”: “long irons, hybrids, driver (thin hits, chunk hits, or slicing right)”
},
“training_schedule”: {
“frequency”: “2 days per week”,
“session_length”: “45 minutes”,
“start_date”: “2024-03-01”,
“end_date”: “2024-03-31”
},
“weekly_routine”: [
{
“day”: “Tuesday”,
“focus”: “Iron Contact and Accuracy”,
“drills”: [
{
“name”: “Low Point Control Drill”,
“description”: “Practice hitting balls with a focus on controlling the low point of your swing to ensure contact with the ball first.”,
“equipment_needed”: [
“irons”,
“golf balls”,
“turf mat or driving range”
],
“repetitions”: “5 sets of 5 shots”
},
{
“name”: “Alignment Stick Drill”,
“description”: “Place alignment sticks on the ground to ensure proper foot alignment and target line. Focus on striking balls with your irons while maintaining this alignment.”,
“equipment_needed”: [
“irons”,
“alignment sticks”,
“golf balls”
],
“repetitions”: “4 sets of 5 shots”
}
],
“tips”: “Focus on the consistency of your ball striking. Ensure you’re hitting the ball first, then the turf.”
},
{
“day”: “Friday”,
“focus”: “Driver and Hybrid Control”,
“drills”: [
{
“name”: “Tee Height Drill”,
“description”: “Practice hitting drives off a tee with different heights to improve the launch and reduce slicing. Focus on making solid contact at the correct part of the club face.”,
“equipment_needed”: [
“driver”,
“golf tees”,
“golf balls”
],
“repetitions”: “5 sets of 4 shots”
},
{
“name”: “Hybrid Control Drill”,
“description”: “Take practice swings with your hybrid focusing on maintaining a slow and controlled tempo. Then try hitting balls with the same tempo.”,
“equipment_needed”: [
“hybrid clubs”,
“golf balls”,
“turf mat or driving range”
],
“repetitions”: “5 sets of 4 shots”
}
],
“tips”: “Work on your grip, posture, and alignment to reduce thin and chunked shots. Improve consistency with your hybrids and driver to control ball flight.”
}
]
}
Any suggestions?