8000 feat: json string values for numbers · Issue #247 · StacDev/stac · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: json string values for numbers #247

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

Closed
aktxyz opened this issue May 14, 2025 · 5 comments
Closed

feat: json string values for numbers #247

aktxyz opened this issue May 14, 2025 · 5 comments
Labels
feature New feature or request

Comments

@aktxyz
Copy link
Contributor
aktxyz commented May 14, 2025

In the code we have that eventually emits json ... everything pops out as a string ... like in this fontSize

          "child": {
            "data": "Home",
            "style": { "fontSize": "24" },
            "type": "text"
          },
          "type": "center"

Just to get past this one scenario, I tweaked the StacTextStyle fromJson to handle this. Can you all thing of a more clever way to handle this?

static StacTextStyle _fromJson(dynamic json) {
    if (json is String) {
      return _$StacTextStyleFromJson({"styleFromTheme": json});
    } else if (json is Map<String, dynamic>) {
      // if string, try parsing !!!!!!!!!!!!!!!!!!!!
      if (json['fontSize'] is String) {
        json['fontSize'] = double.tryParse(json['fontSize']);
      }
      return _$StacTextStyleFromJson(json);
    }

    return _$StacTextStyleFromJson({});
  }
@aktxyz aktxyz added the feature New feature or request label May 14, 2025
@divyanshub024
Copy link
Member

Hey @aktxyz, curious to know why your code is converting everything to "String"? Can you share the snippet?

@aktxyz
Copy link
Contributor Author
aktxyz commented May 14, 2025 8000

Hey @aktxyz, curious to know why your code is converting everything to "String"? Can you share the snippet?

the data originates as XML from a dotnet app ... and gets converted to json via the newtonsoft json package

so <stuff>24<stuff> is converted to "stuff": "24"

@AbhijithKonnayil
Copy link
Contributor

Hi @aktxyz
Does adding the StacDouble solve this problem ? #253
cc @divyanshub024

@divyanshub024
Copy link
Member

Close by #253

@aktxyz
Copy link
Contributor Author
aktxyz commented May 21, 2025

bam yes that solves it !!! thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants
0