Open chaosAD opened 9 years ago
After seeing problem in your design, I suggest the following:
typedef struct {
JsonState state;
} JsonObject;
typedef struct {
TokenType type;
uint32_t startColumn;
uint32_t length;
char *symbol;
Arity arity;
LinkedList *list;
} JsonToken;
Now your jsonParse
function should look like Token *jsonParse(JsonObject *json)
. It returns {
token, which is a JsonToken
. The declaration of JsonToken
should be placed int Token.h
.
The only difference between ordinary Token and JsonToken is token[]
field is replaced with list
. So the JsonToken has symbol = '{'
.
In
please remove
ListState state
. RenameListState
toJsonState
. Instead of polluting your LinkedList with Json information, create the following in JSON.h:which uses LinkedList to store JSON data.
Your
jsonParse
function should look likevoid jsonParse(JsonObject *json)
. It takes in the JSON object which keeps all the information.Create
JsonObject
inJsonObject *createJsonObject()
.