Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Replacing specific array item

Abierto
#64 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
38/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
json, powershell
Área
tooling

Línea de trabajo

Comienza con la página wiki de Replace y reproduce Sample transform 1 contra el JSON proporcionado; después, compáralo con la root-level transform operativa. Rastrea cómo se analiza y aplica un @jdt.path relativo a un array; el trabajo estará terminado cuando cambie el Value del elemento Foo sin depender de su posición ordinal.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

I am having trouble replacing specific array items using the @jdt.path syntax as described on the "Replace" wiki page. The @jdt verbs and attributes don't parse or transform when placed under the array object itself. I was able to get this working by moving the @jdt.replace to the top of the object and then drilling down. Is this a bug?

Sample JSON:

{
  "MyStuff": [
    {
      "Name": "Foo",
      "Value": 123
    },
    {
      "Name": "Bar",
      "Value": 456
    }
  ]
}

The goal is to change the value of the "Foo" item without knowing the ordinal position or how many objects are in the MyStuff array.

Sample transform 1:

{
  "MyStuff": {
    "@jdt.replace": {
      "@jdt.path": "@[?(@.Name == 'Foo')].Value",
      "@jdt.value": 456
    }
  }
}

This should work according to the documentation but all I get is the MyStuff node literally replaced with the transform syntax.

Sample transform 2:

{
  "@jdt.replace": {
    "@jdt.path": "$.MyStuff[?(@.Name == 'Foo')].Value",
    "@jdt.value": 456
  }
}

Alternately, if we place the @jdt.replace at the root and change @jdt.path to start from the root and navigate into MyStuff, it works as expected.

I'm using Visual Studio 2022 + SlowCheetah 4.0.50 in a .NET Framework 4.7.2 project.

Lenguaje dominante
PowerShell
Estrellas
117
Forks
38
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/json-document-transforms

Todos los issues de microsoft/json-document-transforms

Issues similares

Más issues de DevTools

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.