-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Binarydata api update - Default json serializer #16319
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
Changes from 6 commits
d09de6c
138b2a5
a70876a
de98cc4
5047c7a
ed4edd8
af836ce
92a611b
5bcd678
7ee660a
6d5e3f5
689fb25
62e41b0
8b56472
6dee1b4
dcd5457
7e12c49
d611072
6576ab5
09c4632
9be5791
7ed8f7d
32a3ef3
2671255
a8b5273
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,9 @@ | |
|
|
||
| import com.azure.core.util.FluxUtil; | ||
| import com.azure.core.util.logging.ClientLogger; | ||
| import com.azure.core.util.serializer.JsonSerializerProviders; | ||
| import com.azure.core.util.serializer.ObjectSerializer; | ||
| import com.azure.core.util.serializer.JsonSerializer; | ||
| import com.azure.core.util.serializer.TypeReference; | ||
| import static com.azure.core.util.FluxUtil.monoError; | ||
|
|
||
|
|
@@ -185,6 +187,25 @@ public static BinaryData fromBytes(byte[] data) { | |
| return new BinaryData(data); | ||
| } | ||
|
|
||
| /** | ||
| * Serialize the given {@link Object} into {@link BinaryData} using the provided {@link JsonSerializer}. This will | ||
| * require the client to configure Json serializer in classpath. | ||
| * | ||
| * @param data The {@link Object} which needs to be serialized into bytes. | ||
| * @throws NullPointerException if {@code data} is null. | ||
|
hemanttanwar marked this conversation as resolved.
Outdated
|
||
| * @throws IllegalStateException If cannot find any JSON serializer provider on the classpath. | ||
|
hemanttanwar marked this conversation as resolved.
Outdated
|
||
| * @return {@link BinaryData} representing binary data. Or {@code null} if it fails to serialize the data. | ||
|
hemanttanwar marked this conversation as resolved.
Outdated
|
||
| * | ||
| * @see JsonSerializer | ||
| */ | ||
| public static BinaryData fromObject(Object data) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given this API is converting into JSON we may want to call it
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we change it, we need to sync with .Net. I copied this API name from them. |
||
| Objects.requireNonNull(data, "'data' cannot be null."); | ||
|
hemanttanwar marked this conversation as resolved.
Outdated
|
||
|
|
||
| final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); | ||
| JsonSerializerProviders.createInstance().serialize(outputStream, data); | ||
|
alzimmermsft marked this conversation as resolved.
Outdated
|
||
| return new BinaryData(outputStream.toByteArray()); | ||
| } | ||
|
|
||
| /** | ||
| * Serialize the given {@link Object} into {@link BinaryData} using the provided {@link ObjectSerializer}. | ||
| * | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.