Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

ArrayStoreException: Unable to use gson in swift framework #15

Description

@sardarasmita

I am trying to get Gson through j2objc such that I can use it for my iOS swift framework. I am using J2ObjC 2.8 and GSON 2.8.5. and all the classes are translating correctly. However, while running the tests, I cannot successfully convert the data using GSON as the function throws the error.

Java Code

public class Request {
    private String name;
    private String description;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
    
    public void setDescription(String description) {
        this.description = description;
    }
    
    public String getDescription() {
        return description;
    }    
}
public class AService {
	public String getGsonString(Request request) {
		Gson gson = new Gson();
		return gson.toJson(request);
	}
}

I am using the converted code of the above code to run the test case in the swift project

func testGsonString(){
        let request = ComRequest()
        request?.setNameWith("name")
        request?.setDescriptionWith("description")
        let response = ComAService().getGsonString(with: request!)
        XCTAssertNotNil(response)
    }

While running the above code, The ComAService().getGsonString(with: request!) throws error

I have used j2objc-maven-plugin 1.1.4 for conversion and gson 2.8.5.

I require gson to convert string to object or object to a string so that I can use the converted string to store in the local database and vice versa

130604697-9a487673-8692-47f4-888a-6d5652e337bf

130604735-578ae5d5-ce31-4386-8c4f-22251c606b19

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions