docs icon indicating copy to clipboard operation
docs copied to clipboard

How to serialize frontend JS into objects?

Open laolaolulu opened this issue 6 months ago • 1 comments

Type of issue

Other (describe below)

Description

How to serialize frontend JS into objects?

[Enter feedback here]

Page URL

https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/preserve-references

Content source URL

https://github.com/dotnet/docs/blob/main/docs/standard/serialization/system-text-json/preserve-references.md

Document Version Independent Id

2a41a172-f143-ccb7-bc0c-52b7f38d5728

Platform Id

218b8c7e-1de1-df04-dc91-1821e4869747

Article author

@gewarren

Metadata

  • ID: c990a40d-17dd-016e-cea0-7ea90dc82701
  • PlatformId: 218b8c7e-1de1-df04-dc91-1821e4869747
  • Service: dotnet-fundamentals

Related Issues

laolaolulu avatar May 25 '25 05:05 laolaolulu

Hello @laolaolulu! If by "frontend JS" you mean the content of the JS script launch in a certain page, then you can use HttpClient to simply pull all of the page content, including the script, and only then serialize that extracted JS content with System.Text.Json.

Be aware though, that the JS (JavaScript) code that you will somehow extract from the page will not be an object, but just a code, which means it's not serializable to JSON as is. Of course unless I misunderstood your question.

BartoszKlonowski avatar May 29 '25 15:05 BartoszKlonowski