Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected BEGIN_OBJECT but was STRING at path $.transactions[0].in_msg.source #94

Open
jerry-nerd opened this issue Dec 11, 2024 · 0 comments

Comments

@jerry-nerd
Copy link

jerry-nerd commented Dec 11, 2024

I cannot get transactions by tonlib due to #93, so I requested by http to toncenter,and then parse to object in tonlib.

But there are problems:

  1. The toncenter /getTransactions interface response body with result as the transaction array,but in RawTransactions(tonlib), it need transactions as transaction array, so I changed the key result to transactions
        JsonObject jsonObject = JsonParser.parseString(body).getAsJsonObject();
        JsonElement res = jsonObject.getAsJsonArray("result");
        jsonObject.remove("result");
        jsonObject.add("transactions",res);
        RawTransactions txs = (RawTransactions)gson.fromJson(jsonObject, RawTransactions.class);
  1. After step1, when I use gson to switch Json to RawTransactions object, it output error:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at path $.transactions[0].in_msg.source

How can I switch toncenter response to RawTransactions success ?

The toncenter response is like this:

{
  "ok": true,
  "result": [
    {
      "@type": "raw.transaction",
      "address": {
        "@type": "accountAddress",
        "account_address": "EQAGqoVuqErom1b0-oi4lzcViFmeaAH29X3vGiD3pdvW9Z3k"
      },
      "utime": 1732954604,
      "data": "te6cckECDgEAAqQAA7VwaqhW6oSuibVvT6iLiXNxWIWZ5oAfb1fe8aIPel29b1AAAuvpruuIGr9f0egIuoOFwo4n/n2WSu+zmGvOam9n+cotZA8d0rfwAALrWmay0FZ0rJ7AADRlg6UoAQIDAgHgBAUAgnISTylkLH9urHg2lKZWIGg3y2y3Fa2ysArfpqV593ZmLszr/I5urWGMcdNZlq3siwT86VBcx+mF5DeF0B0q3/B0AhkEoXNJAX14QBhlAKoRDA0BsWgBzNfnmGeEDx5Ep87oqxO33hhfbV25aEub1EcGPhj7fV8AAaqhW6oSuibVvT6iLiXNxWIWZ5oAfb1fe8aIPel29b1QF9eEAAYWBYwAAF19NYHjhM6Vk8zABgEB3woBGKMsWb8AAAAAAAAAewcBAdEIAQrxOB5bAQkBZmIAczX55hnhA8eRKfO6KsTt94YX21duWhLm9RHBj4Y+31efJw4AAAAAAAAAAAAAAAAAAQsBr2gADVUK3VCV0Tat6fURcS5uKxCzPNAD7er73jRB70u3resAOZr88wzwgePIlPndFWJ2+8ML7au3LQlzeojgx8Mfb6vPk4cABg5ISAAAXX013XEEzpWT2MALAKMPin6lAAAAAAAAAAAicQgBzNfnmGeEDx5Ep87oqxO33hhfbV25aEub1EcGPhj7fV8AAaqhW6oSuibVvT6iLiXNxWIWZ5oAfb1fe8aIPel29b1BAJ5DM6wPQkAAAAAAAAAAAM8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG/JhVsYTA5IMAAAAAAAAgAAAAAAA1Z+g1EvUEzCqnUpLyVHCyl41xbEycq4pl5vX4z3KKfiQJAqRGVHjf0=",
      "transaction_id": {
        "@type": "internal.transactionId",
        "lt": "51396178000001",
        "hash": "rcq121FYwmo0yN2noQWie1822c9/WqEpJZdI3QUtTt4="
      },
      "fee": "3359053",
      "storage_fee": "34253",
      "other_fee": "3324800",
      "in_msg": {
        "@type": "raw.message",
        "source": "EQDma_PMM8IHjyJT53RVidvvDC-2rty0Jc3qI4MfDH2-r9BZ",
        "destination": "EQAGqoVuqErom1b0-oi4lzcViFmeaAH29X3vGiD3pdvW9Z3k",
        "value": "100000000",
        "fwd_fee": "721606",
        "ihr_fee": "0",
        "created_lt": "51396175000002",
        "body_hash": "/J/0NpXk6a8+TdBDJ78JRNzV/+QqBoNVChJxq8iRMzg=",
        "msg_data": {
          "@type": "msg.dataRaw",
          "body": "te6cckEBBQEApQABGKMsWb8AAAAAAAAAewEBAdECAQrxOB5bAQMBZmIAczX55hnhA8eRKfO6KsTt94YX21duWhLm9RHBj4Y+31efJw4AAAAAAAAAAAAAAAAAAQQAow+KfqUAAAAAAAAAACJxCAHM1+eYZ4QPHkSnzuirE7feGF9tXbloS5vURwY+GPt9XwABqqFbqhK6JtW9PqIuJc3FYhZnmgB9vV97xog96Xb1vUHRa/mM",
          "init_state": ""
        },
        "message": "oyxZvwAAAAAAAAB7\n"
      },
      "out_msgs": [
        {
          "@type": "raw.message",
          "source": "EQAGqoVuqErom1b0-oi4lzcViFmeaAH29X3vGiD3pdvW9Z3k",
          "destination": "EQDma_PMM8IHjyJT53RVidvvDC-2rty0Jc3qI4MfDH2-r9BZ",
          "value": "15000000",
          "fwd_fee": "468004",
          "ihr_fee": "0",
          "created_lt": "51396178000002",
          "body_hash": "TetkDzRVoanx6YpsGNmX0kLoD6AbLYKcv87Euscs/Js=",
          "msg_data": {
            "@type": "msg.dataRaw",
            "body": "te6cckEBAQEAVAAAow+KfqUAAAAAAAAAACJxCAHM1+eYZ4QPHkSnzuirE7feGF9tXbloS5vURwY+GPt9XwABqqFbqhK6JtW9PqIuJc3FYhZnmgB9vV97xog96Xb1vUGC9BVh",
            "init_state": ""
          },
          "message": "D4p+pQAAAAAAAAAAInEIAczX55hnhA8eRKfO6KsTt94YX21duWhLm9RHBj4Y+31fAAGqoVuqErom\n1b0+oi4lzcViFmeaAH29X3vGiD3pdvW9QA==\n"
        }
      ]
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant