Skip to content

How send a complex object via the API ? #75

Open

Description

@afaucogney

How can I implement saving a complex object from Android to the Server.
The object is defined as object type on the server, and on Android is a Hashmap of subObjects, which are itself hashmaps.

Activity

  1. bajtos commented on Jun 2, 2015

    @bajtos
    Contributor

    What have you tried so far? What were the results?

  2. afaucogney commented on Jun 16, 2015

    @afaucogney
    Author

    Sorry, I didn"t get notified you answer me....

    I get an error : "Unprocessable Entity".
    I have a Objet that is composed with subObjects that contains HashMaps members.

    I deal with the code until the Object.toMap() return a JSON like file..... but still something wrong. What are the rules to extends Model with it own Object, especially when there is composition pattern.

  3. afaucogney commented on Jun 16, 2015

    @afaucogney
    Author

    When I logged Obj.toMap().toString(), I get

    {wineColor=1, id=Bouche:Equilibre, wineType=1, oenoLevel=1, instruction={what=Pas d information, how=Pas d information, why=Pas d information}, tripTag=Bouche:Equilibre}

    When I update (replace = by : and adding ") this text to {
    "wineColor":1,
    "id":"Bouche:Equilibre",
    "wineType":1,
    "oenoLevel":1,
    "instruction":
    {
    "what":"Pas d information",
    "how":"Pas d information",
    "why":"Pas d information"
    },
    "tripTag":"Bouche:Equilibre"}

    and I put in the Loopback Explorer, this work with the API, but not from the Client

  4. afaucogney commented on Jun 19, 2015

    @afaucogney
    Author

    @bajtos any news or comment to help ?

  5. bajtos commented on Jun 19, 2015

    @bajtos
    Contributor

    The SDK uses JsonUtil to convert from Java objects to JSON representation. See this unit-test for an example what is the correct way of creating nested object structures.

    Try to enable ADB debug logs, the SDK is logging all request data via Log.d (source code). That way you should see what JSON was produced from your data.

    I am afraid I don't have much time to investigate this. It would help me a lot if you could create a standalone app (LoopBack server, Android client) that I could run on my machine to reproduce the problem.

  6. jjhesk commented on Jul 22, 2016

    @jjhesk

    I would make it one flatten into string then using the string and pass it into the url. Using Gson to flatten the object and parse it into the url.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions