私は以下のコードがあります。タイプの未処理の例外「Newtonsoft.Json.JsonReaderException」
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.Model;
using Amazon.Runtime;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
using (FileStream fs = new FileStream(@"c:\Users\\Desktop\abc.json", FileMode.Open, FileAccess.Read))
using (StreamReader sr = new StreamReader(fs))
using (JsonTextReader reader = new JsonTextReader(sr))
{
while (reader.Read())
{
if (reader.TokenType == JsonToken.StartObject)
{
JObject obj = JObject.Load(reader);
var device_id = obj["device_id"];
Console.WriteLine(device_id);
}
}
Console.ReadLine();
}
}
}
}
コンテンツabc.jsonファイルをエラーが上に来ても
{"_id":{"$oid":"552fcdd61718285a7402aeea"},"gateway_id":2,"device_id":28,"date_time":1.429196246258e+12,"data":[{"r":203,"v":2509},{"r":221,"v":3037},{"r":400,"v":0},{"r":401,"v":0},{"r":402,"v":0},{"r":403,"v":0},{"r":404,"v":0},{"r":405,"v":0},{"r":406,"v":0},{"r":407,"v":0},{"r":408,"v":0},{"r":409,"v":0},{"r":1000,"v":0},{"r":1001,"v":0},{"r":1002,"v":3},{"r":1003,"v":21895},{"r":1004,"v":2500}]}
{"_id":{"$oid":"552fcdd61718285a7402aeeb"},"gateway_id":2,"device_id":29,"date_time":1.429196246989e+12,"data":[{"r":203,"v":2468},{"r":221,"v":2989},{"r":400,"v":0},{"r":401,"v":0},{"r":402,"v":0},{"r":403,"v":0},{"r":404,"v":0},{"r":405,"v":0},{"r":406,"v":0},{"r":407,"v":0},{"r":408,"v":0},{"r":409,"v":0},{"r":1000,"v":0},{"r":1001,"v":0},{"r":1002,"v":3},{"r":1003,"v":8841},{"r":1004,"v":2400}]}
{"_id":{"$oid":"552fcdd71718285a7402aeec"},"gateway_id":2,"device_id":30,"date_time":1.429196247718e+12,"data":[{"r":203,"v":61536},{"r":221,"v":3055},{"r":400,"v":129},{"r":401,"v":32},{"r":402,"v":18064},{"r":403,"v":16435},{"r":404,"v":0},{"r":405,"v":0},{"r":406,"v":0},{"r":407,"v":0},{"r":408,"v":0},{"r":409,"v":0},{"r":1000,"v":1},{"r":1001,"v":1},{"r":1002,"v":3},{"r":1003,"v":20898},{"r":1004,"v":2100}]}
{"_id":{"$oid":"552fcde31718285a7402aeed"},"gateway_id":1,"device_id":28,"date_time":1.429196259149e+12,"data":[{"r":203,"v":2419},{"r":221,"v":2969},{"r":400,"v":0},{"r":401,"v":0},{"r":402,"v":0},{"r":403,"v":0},{"r":404,"v":0},{"r":405,"v":0},{"r":406,"v":0},{"r":407,"v":0},{"r":408,"v":0},{"r":409,"v":0},{"r":1000,"v":1},{"r":1001,"v":1},{"r":1002,"v":3},{"r":1003,"v":26674},{"r":1004,"v":1400}]}
{"_id":{"$oid":"552fcde31718285a7402aeee"},"gateway_id":1,"device_id":29,"date_time":1.429196259879e+12,"data":[{"r":203,"v":2440},{"r":221,"v":2882},{"r":400,"v":0},{"r":401,"v":0},{"r":402,"v":0},{"r":403,"v":0},{"r":404,"v":0},{"r":405,"v":0},{"r":406,"v":0},{"r":407,"v":0},{"r":408,"v":0},{"r":409,"v":0},{"r":1000,"v":1},{"r":1001,"v":1},{"r":1002,"v":3},{"r":1003,"v":22319},{"r":1004,"v":2200}]}
を下回っています行while(reader.Read())。さらに、上記のコードは1GBまでの大規模なjsonファイルを読み込むのに適していますか?ありがとう
エラーメッセージの詳細を投稿できますか? –
通常、JsonReaderExceptionには、何が間違っているのかを正確に伝える関連エラーメッセージがスローされます。すべての例外の詳細を私どもと共有してください。 – Maritim
@Maritim追加情報:JSONコンテンツの読み込みが完了した後で追加テキストが見つかりました:{。パス "、2行目、0桁です。詳細は –