Skip to content

[LitJSON.JsonMapper]::ToObject Error in Powershell #113

Open

Description

@darkquasar

Essentially, you can't use [LitJSON.JsonMapper]::ToObject($WhatEverPSObject) in Powershell from v2 to v5. We get error:

format-default : The JsonData instance has to be initialized first
    + CategoryInfo          : NotSpecified: (:) [format-default], InvalidOperationException
    + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.FormatDefaultCommand

This has been raised 6 years ago here: https://stackoverflow.com/questions/16799634/litjson-error-in-powershell

Regards

Activity

  1. grantfar commented on Nov 22, 2019

    @grantfar
    Contributor

    I will take this

  2. grantfar commented on Nov 22, 2019

    @grantfar
    Contributor

    This is definitely an issue with Powershell. Powershell seems to be calling GetEnumerator () for every JsonData instance regardless if it's actually enumerable. I don't know how to fix this without rewriting most of the program.

  3. devlead commented on Nov 22, 2019

    @devlead
    Member

    So see if it's even worth the effort what's the use case for LitJson that PowerShell built-in ConvertFrom-Json and ConvertTo-Json doesn't solve?

  4. darkquasar commented on Dec 5, 2019

    @darkquasar
    Author

    The use case is simple: to be able to do the same thing ConvertFrom-Json and ConvertTo-Json does but in very old systems that only support Powershell V2 and don't have the necessary modules to even load the V2 version of it like this one: https://stackoverflow.com/questions/28077854/powershell-2-0-convertfrom-json-and-convertto-json-implementation

    I've encountered systems where nothing but LitJSON would work. OFC, this is not a very compelling argument in favor of spending dev time on this, but it depends on the reasonable expectations that old systems are still around :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions