-
Notifications
You must be signed in to change notification settings - Fork 184
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
[WIP] Avoid intermediate values when serializing and deserializing proto3 JSON #670
base: master
Are you sure you want to change the base?
Changes from 6 commits
84c6bc8
662efa9
81ddd0c
3594c5d
a64b2f3
a549b57
b8ef37d
fa4d2ea
f155f11
24bffd5
7c92089
6fa98c8
38079b0
a737185
9b62b5d
d44a919
78d495e
c8895c7
e6bee93
add7cce
513d01e
951a2c9
00003ce
48804f1
a5a3f98
dd8cb85
4d43c95
6fe0731
333f16c
a890105
eaa0d35
14bffa2
0e28eb3
02a9960
7899d1f
ee3cf27
617c30c
712cae7
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 |
---|---|---|
|
@@ -223,6 +223,13 @@ abstract class GeneratedMessage { | |
{TypeRegistry typeRegistry = const TypeRegistry.empty()}) => | ||
_writeToProto3Json(_fieldSet, typeRegistry); | ||
|
||
String toProto3JsonString( | ||
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. Should this really be called 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. Additions in this PR will be inconsistent unless we want to do breaking changes. Currently in master branch (and also in the latest release) we have these generators:
So the proto3 method is already inconsistent. Without changing it, we can name the new methods Should we rename 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. Argh - I see - I introduced that inconsistency - not sure what is the better path forwards.
If we prefer to avoid churn over consistency we keep it as I guess it's up to your judgement. |
||
{TypeRegistry typeRegistry = const TypeRegistry.empty()}) { | ||
StringBuffer buf = StringBuffer(); | ||
_writeToProto3JsonSink(_fieldSet, typeRegistry, buf); | ||
return buf.toString(); | ||
} | ||
|
||
/// Merges field values from [json], a JSON object using proto3 encoding. | ||
/// | ||
/// Well-known types and their special JSON encoding are supported. | ||
|
@@ -257,6 +264,18 @@ abstract class GeneratedMessage { | |
_mergeFromProto3Json(json, _fieldSet, typeRegistry, ignoreUnknownFields, | ||
supportNamesWithUnderscores, permissiveEnums); | ||
|
||
void mergeFromProto3JsonString(String jsonString, | ||
{TypeRegistry typeRegistry = const TypeRegistry.empty(), | ||
bool ignoreUnknownFields = false, | ||
bool supportNamesWithUnderscores = true, | ||
bool permissiveEnums = false}) { | ||
final Proto3JsonParserParams params = Proto3JsonParserParams(typeRegistry, | ||
ignoreUnknownFields: ignoreUnknownFields, | ||
supportNamesWithUnderscores: supportNamesWithUnderscores, | ||
permissiveEnums: permissiveEnums); | ||
_mergeFromProto3JsonString(jsonString, _fieldSet, params); | ||
} | ||
|
||
/// Merges field values from [data], a JSON object, encoded as described by | ||
/// [GeneratedMessage.writeToJson]. | ||
/// | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider passing an "indent" value