json4s / json4s/json4s

How to just get the parent "name" with LINQ style?

Open
#401 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Scala
Stars
1.5k
Forks
324
Avg merge
4h 35m
Merged PRs (30d)
30

Description

Hi, my json like:

{ "name": "joe",
           "children": [
             {
               "name": "Mary",
               "age": 5
             },
             {
               "name": "Mazy",
               "age": 3
             }
           ]
         }

I want to get just parent name, how should I do?

if I do

val json = parse("""
         { "name": "joe",
           "children": [
             {
               "name": "Mary",
               "age": 5
             },
             {
               "name": "Mazy",
               "age": 3
             }
           ]
         }
       """)

  val t =  json \\ "name " 

This would give me all the list of name instead of just give me parents name.

res1: org.json4s.JValue = JObject(List((name,JString(joe)), (name,JString(Mary)), (name,JString(Mazy))))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no source file, test, or entry point; it only provides a JSON example and a json4s query. Start by reproducing the query and checking the project’s query/operator documentation, with completion defined as a tested way to select only the root name.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.