Title: Any way to specify that an array property should be serialized without a property key? · Issue #32 · StringEpsilon/PhpSerializerNET · GitHub
Open Graph Title: Any way to specify that an array property should be serialized without a property key? · Issue #32 · StringEpsilon/PhpSerializerNET
X Title: Any way to specify that an array property should be serialized without a property key? · Issue #32 · StringEpsilon/PhpSerializerNET
Description: I'm writing an application that needs to be compatible with a legacy client whose code I can't change. I have an issue where I have an object that has a nested array. The client expects the array to be serialized without a string key. It...
Open Graph Description: I'm writing an application that needs to be compatible with a legacy client whose code I can't change. I have an issue where I have an object that has a nested array. The client expects the array t...
X Description: I'm writing an application that needs to be compatible with a legacy client whose code I can't change. I have an issue where I have an object that has a nested array. The client expects the...
Opengraph URL: https://github.com/StringEpsilon/PhpSerializerNET/issues/32
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Any way to specify that an array property should be serialized without a property key?","articleBody":"I'm writing an application that needs to be compatible with a legacy client whose code I can't change.\r\n\r\nI have an issue where I have an object that has a nested array. The client expects the array to be serialized without a string key. It's just indexed starting with `i:0`.\r\n\r\nE.g.\r\n\r\nMy class:\r\n\r\n```\r\npublic class MyClass\r\n{\r\n // How to avoid the `objects` key prefix?\r\n public List\u003cObjects\u003e? objects { get; set; }\r\n\r\n [PhpProperty(\"some_string\")]\r\n public string? some_string{ get; set; }\r\n\r\n [PhpProperty(\"some_string2\")]\r\n public string? some_string2{ get; set; }\r\n\r\n [PhpProperty(\"some_string3\")]\r\n public string? some_string3{ get; set; }\r\n\r\n [PhpProperty(\"some_string4\")]\r\n public string? some_string4{ get; set; }\r\n}\r\n```\r\n\r\nanother option I tried was just using an object but not a list:\r\n\r\n```\r\n // How to have this be an integer index?\r\n public Objects? objects { get; set; }\r\n```\r\n\r\nThe output I'm hoping to match would look like this:\r\n\r\n```\r\n// Notice the array index `0` is used without any string key\r\na:5:{i:0;a:2:\r\n```\r\n\r\nWhat I'm actually getting [List version]:\r\n\r\n```\r\na:5:{s:7:\"objects\";a:1:{i:0;a:2:\r\n```\r\n\r\nWhat I'm getting [without List version]:\r\n\r\n```\r\na:5:{s:7:\"objects\";a:2:\r\n```\r\n\r\nThanks in advance.","author":{"url":"https://github.com/mrhappyasthma","@type":"Person","name":"mrhappyasthma"},"datePublished":"2022-04-17T05:24:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":13},"url":"https://github.com/32/PhpSerializerNET/issues/32"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:df977551-4d89-d061-2d93-b00467ab0a58 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DD6C:9D1CD:4F76AB1:7032DDD:6A4FD4C2 |
| html-safe-nonce | 93699f688f14b3da6e2e92b10496d43b31908c29730dd59cdf177c495c0f4c2a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDZDOjlEMUNEOjRGNzZBQjE6NzAzMkRERDo2QTRGRDRDMiIsInZpc2l0b3JfaWQiOiI2OTI1MzA1MDM3NjQ5MzM1NDkwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 63aab52609e04003fe51fccc7dc95c5605822d8cb13673b1478f8eb95f0992c7 |
| hovercard-subject-tag | issue:1206285101 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/StringEpsilon/PhpSerializerNET/32/issue_layout |
| twitter:image | https://opengraph.githubassets.com/df6b159d9a3c6748a6f852eaf1b468b4491a0d719572d26a6e81f6514eb252f6/StringEpsilon/PhpSerializerNET/issues/32 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/df6b159d9a3c6748a6f852eaf1b468b4491a0d719572d26a6e81f6514eb252f6/StringEpsilon/PhpSerializerNET/issues/32 |
| og:image:alt | I'm writing an application that needs to be compatible with a legacy client whose code I can't change. I have an issue where I have an object that has a nested array. The client expects the array t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mrhappyasthma |
| hostname | github.com |
| expected-hostname | github.com |
| None | 19b98c3d9767bb8a56238a89ff8401d1cbdf3bc5c353799aacf49fe6c76b4b7c |
| turbo-cache-control | no-preview |
| go-import | github.com/StringEpsilon/PhpSerializerNET git https://github.com/StringEpsilon/PhpSerializerNET.git |
| octolytics-dimension-user_id | 5951778 |
| octolytics-dimension-user_login | StringEpsilon |
| octolytics-dimension-repository_id | 403361593 |
| octolytics-dimension-repository_nwo | StringEpsilon/PhpSerializerNET |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 403361593 |
| octolytics-dimension-repository_network_root_nwo | StringEpsilon/PhpSerializerNET |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 142593e66413bbae27fd485859993597d5a3b104 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width