{"action":"created","issue":{"url":"https://api.github.com/repos/google/flatbuffers/issues/3809","repository_url":"https://api.github.com/repos/google/flatbuffers","labels_url":"https://api.github.com/repos/google/flatbuffers/issues/3809/labels{/name}","comments_url":"https://api.github.com/repos/google/flatbuffers/issues/3809/comments","events_url":"https://api.github.com/repos/google/flatbuffers/issues/3809/events","html_url":"https://github.com/google/flatbuffers/issues/3809","id":139508499,"number":3809,"title":"Java produce a huge and different byte array result from C++","user":{"login":"ggveasna","id":1555609,"avatar_url":"https://avatars.githubusercontent.com/u/1555609?v=3","gravatar_id":"","url":"https://api.github.com/users/ggveasna","html_url":"https://github.com/ggveasna","followers_url":"https://api.github.com/users/ggveasna/followers","following_url":"https://api.github.com/users/ggveasna/following{/other_user}","gists_url":"https://api.github.com/users/ggveasna/gists{/gist_id}","starred_url":"https://api.github.com/users/ggveasna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ggveasna/subscriptions","organizations_url":"https://api.github.com/users/ggveasna/orgs","repos_url":"https://api.github.com/users/ggveasna/repos","events_url":"https://api.github.com/users/ggveasna/events{/privacy}","received_events_url":"https://api.github.com/users/ggveasna/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-03-09T08:19:44Z","updated_at":"2016-04-03T06:24:02Z","closed_at":null,"body":"Hi I attempted to build a parser to parse Json to Flatbuffer byte array using the generated class from \r\n`flatc  -j`.\r\n\r\nHowever, the code `builder.dataBuffer()` return an array which is longer and different from the one generate by C++ by comparing the two byte array (Note: I use JNI to convert C++ byte array to Java byte array). The issue is the byte array output from the builder is not reuse able as `ByteBuffer.wrap()` produce a wrong result."},"comment":{"url":"https://api.github.com/repos/google/flatbuffers/issues/comments/204887747","html_url":"https://github.com/google/flatbuffers/issues/3809#issuecomment-204887747","issue_url":"https://api.github.com/repos/google/flatbuffers/issues/3809","id":204887747,"user":{"login":"ggveasna","id":1555609,"avatar_url":"https://avatars.githubusercontent.com/u/1555609?v=3","gravatar_id":"","url":"https://api.github.com/users/ggveasna","html_url":"https://github.com/ggveasna","followers_url":"https://api.github.com/users/ggveasna/followers","following_url":"https://api.github.com/users/ggveasna/following{/other_user}","gists_url":"https://api.github.com/users/ggveasna/gists{/gist_id}","starred_url":"https://api.github.com/users/ggveasna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ggveasna/subscriptions","organizations_url":"https://api.github.com/users/ggveasna/orgs","repos_url":"https://api.github.com/users/ggveasna/repos","events_url":"https://api.github.com/users/ggveasna/events{/privacy}","received_events_url":"https://api.github.com/users/ggveasna/received_events","type":"User","site_admin":false},"created_at":"2016-04-03T06:24:02Z","updated_at":"2016-04-03T06:24:02Z","body":"@gwvo Here is my command line for generate binary and json\r\n\r\n1. Command to generate binary `flatc -b page.fbs page.json`\r\n2. Command to generate Json  `flatc -t page.fbs -- page.bin`\r\n\r\nYou can see my FlatBuffer schema and the json file with link below\r\nhttps://gist.github.com/ggveasna/170df3181972400695d51cac32b5bedf\r\n\r\nLet me know if something wrong with the command above and my FlatBuffer schema.\r\n\r\nIn this case, I only verify with C++ parser via command line. As for java code that I generate it seem like I miss the file extension and file identifier. First I try with option `--raw-binary` but after I look into the C++ parser code, it seem that it required file identifier to be present in the binary buffer.\r\n\r\nAs for your suggestion, I'm not really sure. I haven't work on C++ much. I know Java more than C and C++. My understanding is that, option a and b is required to debug through C++ code during process of parsing and it mind take me sometime as I don't really work on C++. Please correct me if I am wrong.\r\n\r\nFor option c, I do use manually Java code to construct a buffer. The generated code is only generate a Java code where it call to the Java code which is generated by `flatc -j`.\r\n\r\nThanks"}}