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

InvalidProtocolBuffer thrown when serialising array data #82

Open
Siretfel opened this issue May 25, 2016 · 0 comments
Open

InvalidProtocolBuffer thrown when serialising array data #82

Siretfel opened this issue May 25, 2016 · 0 comments

Comments

@Siretfel
Copy link

Hello I am using the latest protobuf.io library and I am facing an issue with array elements.

My code is

NSString *requestString = @"http://url/journal/";
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:requestString]];
NSError* error;
NSArray *jsonDataArray = [[NSArray alloc] initWithArray:[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error]];

NSDictionary *dictObject = [jsonDataArray objectAtIndex:1];
//NSLog(@"%@", [dictObject valueForKey:@"deviceA"]);
NSData *jsonJobData = [NSJSONSerialization dataWithJSONObject:dictObject options:kNilOptions error:&error];
JournalEntry  *aJobEntry = [JournalEntry parseFromData:jsonJobData];

and the json input is

(
        {
        callGroupId = 1458762093348;
        callType = "NOT_RESPONDING";
        callerInfoB =         (
                        {
                firstName = "";
                lastName = M5T2;
              }
        );
        createdTime = 1460633282;
        deviceA = "++30(210)3453-342";
        deviceB = 109;
        direction = INCOMING;
        duration = 0;
     },
        {
        callGroupId = 1458762093361;
        callType = "NOT_RESPONDING";
        callerInfoB =         (
                        {
                firstName = "";
                lastName = M5T5;
            }
        );
        createdTime = 1460634071;
        deviceA = "+30(210)3453-342";
        deviceB = 108;
        direction = INCOMING;
        duration = 0;
    }
)

The library complains for an invalid protocol buffer and crashes when parseFromData is used. In general I am facing problems in order to map arrays of NSDictionaries to protobuf objects. What am I doing wrong?

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