Data abort when trying to create Jansson object.

Discussion in '3DS - Homebrew Development and Emulators' started by moriczgergo, Jul 29, 2017.

  1. moriczgergo
    OP

    moriczgergo GBAtemp Regular

    Member
    112
    76
    Dec 28, 2016
    Hungary
    Between table and chair, chugging water.
    I am currently trying to make a Jansson JSON object and then "stringify" it for some other function I use that needs JSON.

    Code:
    #include <jansson.h>
    #include <3ds.h>
    
    int myFunction(int* setErr) {
        json_t* req = json_object();
        *setErr = json_string_set(json_object_get(req, "email"), "foo");
        if(setErr != 0){
            return -1;
        }
        *setErr = json_string_set(json_object_get(req, "password"), "bar");
        if(setErr != 0){
            return -1;
        }
        someOtherFuncion(json_dumps(req, JSON_COMPACT));
        return 0;
    }
    
    According to addr2line, line 6 (*setErr = json_string_set(...)) is causing a data abort exception.

    What is the correct way to create a JSON object from scratch?