parsing user input into predefined json format

58 Views Asked by At

I'm building a workout app and I've been wrestling with how to enable users to define their exercises. I want to avoid multiple text fields of input and i was hoping to allow users to enter the whole thing via text and then parse their entry into my predefined model for a workout.

There aren't infinite ways to define exercises in a workout ("3 sets of 10, 9 and 8 reps at 100, 120 and 130 (lbs | kg)", "set 1. 30 seconds with 40 seconds rest, set 2. ...."). So at first i thought about doing simple string parsing but im wondering if there are existing libraries/algorithms/methodologies I could use to help

This is an android app and I'm hoping to do the computation locally

I was also hoping to include implementing auto complete like in google search.

My model is as such, a workout is just a collection of these

var exerciseTemplate = {
"exerciseTemplateId" : UUID,
"exerciseMetadataId" : UUID,
"defaultTargetQuantity": {
    "sets" :{
        {
            "setId":UUID,
            "setOrder": Integer,
            "weight" : Float,
            "unit" : (lbs | kg),
            "reps" : Integer | "time" : Integer | "untilFailure" : Boolean,
            "rest" : Integer
        }
    }
}

}

1

There are 1 best solutions below

0
Canaan On

I have just learned IMS Question & Test Interoperability(QTI) which defines a standard format for the representation of assessment content and results, supporting the exchange of this material between authoring and delivery systems, repositories and other learning management systems.

You can see here if it can help you,but it is XML format.