fromJson

fun fromJson(json: JsonObject): FederationResponse

Parses a JSON response from a SEP-2 federation server into a FederationResponse.

The JSON must contain at minimum the account_id field. All other fields (stellar_address, memo_type, memo) are optional.

JSON Field Mapping

  • stellar_addressstellarAddress

  • account_idaccountId (required)

  • memo_typememoType

  • memomemo

Return

The parsed federation response

Parameters

json

The JSON object returned by the federation server

Throws

if the account_id field is missing

Example:

val json = Json.parseToJsonElement("""
{
"stellar_address": "bob*stellar.org",
"account_id": "GCIBUCGPOHWMMMFPFTDWBSVHQRT4DIBJ7AD6BZJYDITBK2LCVBYW7HUQ",
"memo_type": "id",
"memo": "123"
}
""".trimIndent()).jsonObject

val response = FederationResponse.fromJson(json)