• Resolved Jon

    (@jonadair)


    Hi, I’m struggling to parse my JSON file. This is my JSON:

    {
      "feed_meta": {
        "symbol": "TLEI",
        "exchange": "LON",
        "timestamp": "2022-04-06 13:39:30"
      },
      "feed_data": {
        "1": {
          "id": "market_cap",
          "label": "Market Cap",
          "type": "price",
          "data": "151,164,998.00"
        },
        "2": {
          "id": "current",
          "label": "Current",
          "type": "price",
          "data": "1.31"
        },
        "3": {
          "id": "currency",
          "label": "Currency",
          "type": "text",
          "data": "USD"
        }
      }
    }

    This is the template I’m trying to use:

    <div class="tlei-price">
    	<div class="tlei-price__ticker">
    		<h2>{subloop:feed_meta:-1}{feed_meta.exchange}:{feed_meta.symbol}{/subloop:feed_meta}</h2>
    	</div>
    	<div class="tlei-price__price">
    		<p>{subloop:feed_data:-1}{feed_data.3.data}{feed_data.2.data}{/subloop:feed_data}</p>
    	</div>
    	<div class="tlei-price__as-at">
    		<p>As at {subloop:feed_meta:-1}{feed_meta.timestamp}{/subloop:feed_meta}. Prices delayed by up to 15 minutes.</p>
    	</div>
    </div>

    I haven’t defined a basenode. The data from feed_meta is displayed successfully but nothing is displayed from feed_data – I’m guessing because the objects have a number not a name?

    Hopefully you can help! Many thanks in advance.

    Jon

Viewing 1 replies (of 1 total)
  • Plugin Author berkux

    (@berkux)

    Hi Jon,

    try

    [jsoncontentimporter url=https://api.json-content-importer.com/extra/json/24.json]
    <h2>{subloop:feed_meta:-1}{feed_meta.exchange}:{feed_meta.symbol}{/subloop:feed_meta}</h2>
    <p>{subloop:feed_data:-1}{feed_data.data} - {/subloop:feed_data}</p>
    <p>As at {subloop:feed_meta:-1}{feed_meta.timestamp}{/subloop:feed_meta}. Prices delayed by up to 15 minutes.</p>
    [/jsoncontentimporter]

    and see message in the JCI-Tickets.

    Bernhard

Viewing 1 replies (of 1 total)
  • The topic ‘Navigating JSON with object name as a number’ is closed to new replies.