{"action":"created","issue":{"url":"https://api.github.com/repos/FasterXML/jackson-dataformat-csv/issues/93","labels_url":"https://api.github.com/repos/FasterXML/jackson-dataformat-csv/issues/93/labels{/name}","comments_url":"https://api.github.com/repos/FasterXML/jackson-dataformat-csv/issues/93/comments","events_url":"https://api.github.com/repos/FasterXML/jackson-dataformat-csv/issues/93/events","html_url":"https://github.com/FasterXML/jackson-dataformat-csv/issues/93","id":109909788,"number":93,"title":"CSV mapper does not support Views or filtering correctly for serialization","user":{"login":"triviski","id":432655,"avatar_url":"https://avatars.githubusercontent.com/u/432655?v=3","gravatar_id":"","url":"https://api.github.com/users/triviski","html_url":"https://github.com/triviski","followers_url":"https://api.github.com/users/triviski/followers","following_url":"https://api.github.com/users/triviski/following{/other_user}","gists_url":"https://api.github.com/users/triviski/gists{/gist_id}","starred_url":"https://api.github.com/users/triviski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/triviski/subscriptions","organizations_url":"https://api.github.com/users/triviski/orgs","repos_url":"https://api.github.com/users/triviski/repos","events_url":"https://api.github.com/users/triviski/events{/privacy}","received_events_url":"https://api.github.com/users/triviski/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-06T00:03:09Z","updated_at":"2015-12-14T21:07:16Z","closed_at":null,"body":"I am using views to serialize objects as well as get a more clean query output.  Below is an example of the two JSONs created, one for serialization and the other for query.  \r\n\r\nThe first is a more sanitized view that is given to the user when queried.  The second is a view of what is held in memory and used for serialization.  But these are views of the same data using serialization views. \r\n\r\n```json\r\n{\r\n  \"venue\" : \"ATLO\",\r\n  \"sessionNumber\" : 0,\r\n  \"scid\" : 76,\r\n  \"dssId\" : 0,\r\n  \"vcid\" : 0,\r\n  \"host\" : \"somehost\",\r\n  \"isRealTime\" : false,\r\n  \"channelId\" : \"A-0001\",\r\n  \"dnAlarmState\" : \"Some alarm state\",\r\n  \"euAlarmState\" : \"Some alarm state\",\r\n  \"dnAlarmLevel\" : \"YELLOW\",\r\n  \"euAlarmLevel\" : \"NONE\",\r\n  \"status\" : \"\",\r\n  \"dn\" : 1444088455219,\r\n  \"eu\" : 1.444088455219E12,\r\n  \"sclk\" : \"1444088455.00334\",\r\n  \"ert\" : \"1970-017T17:08:08.4550002\",\r\n  \"scet\" : \"1970-017T17:08:08.455\"\r\n}\r\n{\r\n  \"@class\" : \"jpl.gds.core.globallad.data.EhaGlobalLadData\",\r\n  \"eventTime\" : 1444088455219,\r\n  \"sclkCoarse\" : 1444088455,\r\n  \"sclkFine\" : 219,\r\n  \"ertMilliseconds\" : 1444088455,\r\n  \"ertNanoseconds\" : 219,\r\n  \"scetMilliseconds\" : 1444088455,\r\n  \"scetNanoseconds\" : 219,\r\n  \"venue\" : \"ATLO\",\r\n  \"sessionNumber\" : 0,\r\n  \"scid\" : 76,\r\n  \"dssId\" : 0,\r\n  \"vcid\" : 0,\r\n  \"host\" : \"somehost\",\r\n  \"insertNumber\" : 1,\r\n  \"isRealTime\" : false,\r\n  \"isHeader\" : false,\r\n  \"isMonitor\" : false,\r\n  \"isSse\" : false,\r\n  \"isFsw\" : true,\r\n  \"channelId\" : \"A-0001\",\r\n  \"dnType\" : 0,\r\n  \"dnAlarmState\" : \"Some alarm state\",\r\n  \"euAlarmState\" : \"Some alarm state\",\r\n  \"dnAlarmLevel\" : \"YELLOW\",\r\n  \"euAlarmLevel\" : \"NONE\",\r\n  \"dnRaw\" : \"AAABUDphIDM=\",\r\n  \"euRaw\" : \"QnUDphIDMAA=\",\r\n  \"status\" : \"\"\r\n}\r\n```\r\n\r\nIssue 1:\r\nIf I create a csv schema using an object mapper set up to use the request view (smaller of the pair) the schema still includes everything from the object.  I believe that it should only contain the data configured in the view.  \r\n\r\nWhen I try to set up the mapper with this view I keep getting this very vague error: \"Can not skip a field, expecting a value.\"  \r\n\r\n```\r\ncom.fasterxml.jackson.core.JsonGenerationException: Can not skip a field, expecting a value\r\n\tat com.fasterxml.jackson.core.JsonGenerator._reportError(JsonGenerator.java:1574)\r\n\tat com.fasterxml.jackson.dataformat.csv.CsvGenerator.writeOmittedField(CsvGenerator.java:759)\r\n\tat com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsOmittedField(BeanPropertyWriter.java:592)\r\n\tat com.fasterxml.jackson.databind.ser.impl.FilteredBeanPropertyWriter$SingleView.serializeAsField(FilteredBeanPropertyWriter.java:66)\r\n\tat com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:666)\r\n\tat com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeWithType(BeanSerializerBase.java:552)\r\n\tat com.fasterxml.jackson.databind.ser.impl.TypeWrappedSerializer.serialize(TypeWrappedSerializer.java:32)\r\n\tat com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:129)\r\n\tat com.fasterxml.jackson.databind.ObjectWriter._configAndWriteValue(ObjectWriter.java:1052)\r\n\tat com.fasterxml.jackson.databind.ObjectWriter.writeValueAsString(ObjectWriter.java:923)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:606)\r\n\tat junit.framework.TestCase.runTest(TestCase.java:176)\r\n\tat junit.framework.TestCase.runBare(TestCase.java:141)\r\n\tat junit.framework.TestResult$1.protect(TestResult.java:122)\r\n\tat junit.framework.TestResult.runProtected(TestResult.java:142)\r\n\tat junit.framework.TestResult.run(TestResult.java:125)\r\n\tat junit.framework.TestCase.run(TestCase.java:129)\r\n\tat junit.framework.TestSuite.runTest(TestSuite.java:255)\r\n\tat junit.framework.TestSuite.run(TestSuite.java:250)\r\n\tat org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)\r\n\tat org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)\r\n\tat org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)\r\n\tat org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)\r\n```\r\n\r\nI traced this in my IDE and see that it is expecting values for fields that have been filtered out (not included) in the view.  \r\n\r\nI tried to work around this by using filters instead to no avail.\r\n\r\nIssue 2:  \r\nI set up a filter to mimic the view fro the query data.  \r\n\r\n```java\r\n\t\tList<String> csvColumns = Arrays.asList(\"sessionNumber\", \"host\", \"venue\", \"scid\", \"channelId\",  \"dssId\", \"vcid\", \"ert\", \"scet\", \"sclk\", \"dn\", \"eu\", \"status\", \"dnAlarmState\", \"dnAlarmLevel\", \"euAlarmState\", \"euAlarmLevel\", \"isRealTime\");\r\n```\r\n\r\nI enabled the ignore unknown as well.\r\n\t\tcsvMapper.enable(JsonGenerator.Feature.IGNORE_UNKNOWN);\r\n\r\nThis time the issue is that I am not getting any error, but the column names are not properly calling the getter methods.  Below is the output I am getting. \r\n\r\nsessionNumber,host,venue,scid,channelId,dssId,vcid,ert,scet,sclk,dn,eu,status,dnAlarmState,dnAlarmLevel,euAlarmState,euAlarmLevel,isRealTime\r\n0,somehost,ATLO,76,A-0001,0,0,,,,,,,\"Some alarm state\",YELLOW,\"Some alarm state\",NONE,false\r\n\r\nAs an example, the sclk column should call the \"getSclk\" method since it has the @JsonProperty(\"sclk\") annotation.  \r\n\r\nI hope I did something wrong.  \r\n\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/FasterXML/jackson-dataformat-csv/issues/comments/164560024","html_url":"https://github.com/FasterXML/jackson-dataformat-csv/issues/93#issuecomment-164560024","issue_url":"https://api.github.com/repos/FasterXML/jackson-dataformat-csv/issues/93","id":164560024,"user":{"login":"cowtowncoder","id":55065,"avatar_url":"https://avatars.githubusercontent.com/u/55065?v=3","gravatar_id":"","url":"https://api.github.com/users/cowtowncoder","html_url":"https://github.com/cowtowncoder","followers_url":"https://api.github.com/users/cowtowncoder/followers","following_url":"https://api.github.com/users/cowtowncoder/following{/other_user}","gists_url":"https://api.github.com/users/cowtowncoder/gists{/gist_id}","starred_url":"https://api.github.com/users/cowtowncoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cowtowncoder/subscriptions","organizations_url":"https://api.github.com/users/cowtowncoder/orgs","repos_url":"https://api.github.com/users/cowtowncoder/repos","events_url":"https://api.github.com/users/cowtowncoder/events{/privacy}","received_events_url":"https://api.github.com/users/cowtowncoder/received_events","type":"User","site_admin":false},"created_at":"2015-12-14T21:07:16Z","updated_at":"2015-12-14T21:07:16Z","body":"@rob-baily thanks! This should help figuring out what is going on & fix the issue(s)."}}