Skip to content
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

Unable to convert JSON to python classes #116

Open
theautomationtester99 opened this issue Mar 28, 2024 · 2 comments
Open

Unable to convert JSON to python classes #116

theautomationtester99 opened this issue Mar 28, 2024 · 2 comments

Comments

@theautomationtester99
Copy link

Unable to convert JSON to python classes

below error is displayed.
System.NotSupportedException: Unsupported json type: NullableSomething at Xamasoft.JsonClassGenerator.CodeWriters.PythonCodeWriter.GetTypeName(JsonType type) in C:\Users\Hilal\OneDrive\Desktop\Json2CSharpCodeGenerator\JsonClassGeneratorLib\CodeWriters\PythonCodeWriter.cs:line 54 at Xamasoft.JsonClassGenerator.JsonType.GetTypeName() in C:\Users\Hilal\OneDrive\Desktop\Json2CSharpCodeGenerator\JsonClassGeneratorLib\JsonType.cs:line 157 at Xamasoft.JsonClassGenerator.CodeWriters.PythonCodeWriter.WriteClassMembers(StringBuilder sw, JsonType type, String prefix) in C:\Users\Hilal\OneDrive\Desktop\Json2CSharpCodeGenerator\JsonClassGeneratorLib\CodeWriters\PythonCodeWriter.cs:line 142 at Xamasoft.JsonClassGenerator.CodeWriters.PythonCodeWriter.WriteClass(StringBuilder sw, JsonType type) in C:\Users\Hilal\OneDrive\Desktop\Json2CSharpCodeGenerator\JsonClassGeneratorLib\CodeWriters\PythonCodeWriter.cs:line 95 at Xamasoft.JsonClassGenerator.CodeWriters.PythonCodeWriter.WriteClassesToFile(StringBuilder sw, IEnumerable`1 types, Boolean rootIsArray) in C:\Users\Hilal\OneDrive\Desktop\Json2CSharpCodeGenerator\JsonClassGeneratorLib\CodeWriters\PythonCodeWriter.cs:line 122 at Xamasoft.JsonClassGenerator.JsonClassGenerator.GenerateClasses(String jsonInput, String& errorMessage) in C:\Users\Hilal\OneDrive\Desktop\Json2CSharpCodeGenerator\JsonClassGeneratorLib\JsonClassGenerator.cs:line 78

@AlgoExecutor
Copy link

similar problem here too:
System.ArgumentOutOfRangeException: Length cannot be less than zero. (Parameter 'value') at System.Text.StringBuilder.set_Length(Int32 value) at Xamasoft.JsonClassGenerator.CodeWriters.PythonCodeWriter.WriteClassMembers(StringBuilder sw, JsonType type, String prefix) in C:\Users\Hilal\OneDrive\Desktop\Json2CSharpCodeGenerator\JsonClassGeneratorLib\CodeWriters\PythonCodeWriter.cs:line 152 at Xamasoft.JsonClassGenerator.CodeWriters.PythonCodeWriter.WriteClass(StringBuilder sw, JsonType type) in C:\Users\Hilal\OneDrive\Desktop\Json2CSharpCodeGenerator\JsonClassGeneratorLib\CodeWriters\PythonCodeWriter.cs:line 95 at Xamasoft.JsonClassGenerator.CodeWriters.PythonCodeWriter.WriteClassesToFile(StringBuilder sw, IEnumerable``1 types, Boolean rootIsArray) in C:\Users\Hilal\OneDrive\Desktop\Json2CSharpCodeGenerator\JsonClassGeneratorLib\CodeWriters\PythonCodeWriter.cs:line 122 at Xamasoft.JsonClassGenerator.JsonClassGenerator.GenerateClasses(String jsonInput, String& errorMessage) in C:\Users\Hilal\OneDrive\Desktop\Json2CSharpCodeGenerator\JsonClassGeneratorLib\JsonClassGenerator.cs:line 78

@weljajoh
Copy link

weljajoh commented Dec 6, 2024

Same here:

Exception:
System.ArgumentOutOfRangeException: Length cannot be less than zero. (Parameter 'value') at System.Text.StringBuilder.set_Length(Int32 value) at Xamasoft.JsonClassGenerator.CodeWriters.PythonCodeWriter.WriteClassMembers(StringBuilder sw, JsonType type, String prefix) in C:\Users\Hilal\OneDrive\Desktop\Json2CSharpCodeGenerator\JsonClassGeneratorLib\CodeWriters\PythonCodeWriter.cs:line 152 at Xamasoft.JsonClassGenerator.CodeWriters.PythonCodeWriter.WriteClass(StringBuilder sw, JsonType type) in C:\Users\Hilal\OneDrive\Desktop\Json2CSharpCodeGenerator\JsonClassGeneratorLib\CodeWriters\PythonCodeWriter.cs:line 95 at Xamasoft.JsonClassGenerator.CodeWriters.PythonCodeWriter.WriteClassesToFile(StringBuilder sw, IEnumerable`1 types, Boolean rootIsArray) in C:\Users\Hilal\OneDrive\Desktop\Json2CSharpCodeGenerator\JsonClassGeneratorLib\CodeWriters\PythonCodeWriter.cs:line 122 at Xamasoft.JsonClassGenerator.JsonClassGenerator.GenerateClasses(String jsonInput, String& errorMessage) in C:\Users\Hilal\OneDrive\Desktop\Json2CSharpCodeGenerator\JsonClassGeneratorLib\JsonClassGenerator.cs:line 78

The same JSON snippet converts fine to Java and C#.

{
  "softwareUpdateState":  {
    "status":  {
      "Installing":  {}
    },
    "expectedDurationSec":  3300,
    "downloadPerc":  100,
    "installPerc":  10,
    "version":  "2024.44.25.2",
    "timestamp":  "2024-12-06T08:37:18.750Z"
  }
}

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

No branches or pull requests

3 participants