Repository navigation
Conversation
| } | ||
|
|
||
| /// <summary> | ||
| /// Parses a string representing JSON document into a <see cref="JArray"/>. |
There was a problem hiding this comment.
Maybe we should change the word "document" in JNode.Parse (and JObject.Parse and JArray.Parse) documentation, so that users won't associate it with JsonDocument?
| { | ||
| /// <summary> | ||
| /// The base class that represents a single node within a mutable JSON document. | ||
| /// The base class that represents a single node within a mutable JSON document. See also <see cref="JObject"/> and <see cref="JArray"/> which derive from <see cref="JNode"/>. |
There was a problem hiding this comment.
If we add references to JNode in JsonDocument documentation, maybe it would be worth mentioning JsonDocument in JNode documentation as well?
Maybe it would be better to separate UX study feedback from actual fixes, so I think we should merge my PR first and then this one (with perhaps some more changes after the second day of study results). However, I am not sure when I will be able to address review comments to my PR. |
| public uint GetUInt32() { throw null; } | ||
| [System.CLSCompliantAttribute(false)] | ||
| public ulong GetUInt64() { throw null; } | ||
| public System.Text.Json.Linq.JNode ToJNode() { throw null; } |
|
What's the intent here on using the exact same names as JSON.NET? Aren't we worried about type conflicts? |
|
the intent here was to do a separation of concepts between JsonDocument and JsonElement and the modifiable types for the writable DOM. It might very well be that using the same names as JSON.NET is not the right plan, as it might cause confusion for web searches or stack overflow, but we are currently experimenting and performing UX Studies to see what the right design is. |
| /// Represents a mutable JSON object. | ||
| /// </summary> | ||
| public sealed class JsonObject : JsonNode, IEnumerable<KeyValuePair<string, JsonNode>> | ||
| public sealed partial class JObject : JNode, IEnumerable<KeyValuePair<string, JNode>> |
There was a problem hiding this comment.
I totally support a rename and a new namespace, but I don't think that in general clashing with Json.NET is a good idea.
There was a problem hiding this comment.
The renaming uniforms System.Text.Json.Linq with System.Xml.Linq which uses X prefixes instead of Xml (:
Pretty sure this isn't a great idea. I don't see how this is viable. Applications will pull in both for the foreseeable future (transitively or directly) and it'll clash. |
|
That could still be worked around though, by using aliases or such. That said, I agree with you that I don't feel that having the name clashing is a good idea. I believe that for now we are prototyping different alternatives and see how users react to it, although @ahsonkhan could correct me if that is not the case. |
That's user hostile though. |
| { | ||
| IEnumerator enumerator = _enumerator; | ||
| enumerator.Reset(); | ||
| _enumerator = (List<JNode>.Enumerator)enumerator; |
There was a problem hiding this comment.
You can avoid allocation here via a devirtualization trick:
void IEnumerator.Reset() => ResetCore(_enumerator);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void ResetCore<T>(in T enumerator)
where T : struct, IEnumerator
=> enumerator.Reset();JArray+Enumerator.System.Collections.IEnumerator.Reset()
L0000: push ebp
L0001: mov ebp, esp
L0003: push eax
L0004: mov [ebp-0x4], ecx
L0007: cmp dword [0x1c30c1a8], 0x0
L000e: jz L0015
L0010: call 0x62f15b90
L0015: nop
L0016: mov ecx, [ebp-0x4]
L0019: call dword [0x1c30cd14]
L001f: nop
L0020: nop
L0021: mov esp, ebp
L0023: pop ebp
L0024: ret|
Thank you for your contribution. As announced in dotnet/coreclr#27549 this repository will be moving to dotnet/runtime on November 13. If you would like to continue working on this PR after this date, the easiest way to move the change to dotnet/runtime is:
|
|
@ahsonkhan I suppose this one we want to close? |
| set | ||
| { | ||
| _list[idx] = value ?? new JsonNull(); | ||
| _list[idx] = value ?? new JTreeNull(); |
There was a problem hiding this comment.
Wasn't there just a change to use a singleton of null?
There was a problem hiding this comment.
Yep, in the refactoring PR. Waiting for that one to get merged first, and then will update this PR. This PR won't make it, so I will port it manually to the other repo.
|
Thank you for your contribution. As announced in #27549 the dotnet/runtime repository will be used going forward for changes to this code base. Closing this PR as no more changes will be accepted into master for this repository. If you’d like to continue working on this change please move it to dotnet/runtime. |
|
@ahsonkhan do you plan on moving this one over there? We did add the post-consolidation tag so I thought this wouldn't get closed, but let's just make sure that this work eventually happens. |
I am focused on some other things atm, but yes, I plan to open this up in dotnet/runtime soon (maybe next week). Thanks for the reminder. |
Forked from #41030 (and hence depends on it).
Changes:
Rename JsonNode and related types to JNode, JObject, etc.Rename JsonNode and related types to JTreeNode, JTreeObject, etc.Should we wait for this PR to get merged until after #41041?This PR isn't ready to be merged until more tests are added but a review would help.Very few changes are made to the implementation details. It's probably easiest to review this one commit at a time.
cc @kasiabulat, @terrajobst, @bartonjs, @joperezr